summaryrefslogtreecommitdiff
path: root/src/mongo/util/tcmalloc_server_status_section.cpp
diff options
context:
space:
mode:
authorHenrik Edin <henrik.edin@mongodb.com>2019-02-07 17:22:04 -0500
committerHenrik Edin <henrik.edin@mongodb.com>2019-02-12 10:03:36 -0500
commit530a26bc5387de3dd131a18801a6c3253c4f3220 (patch)
tree6528c61a2938ee5ed9ec5a661084ee2b65fe8804 /src/mongo/util/tcmalloc_server_status_section.cpp
parent7941c8a7424590247f3d6b3bdbad7cff50b8b90c (diff)
downloadmongo-r4.1.8.tar.gz
SERVER-39456 Remove tcmallocEnableMarkThreadTemporarilyIdle implementation.r4.1.8
An error message was added with explaination if this is attempted to be set.
Diffstat (limited to 'src/mongo/util/tcmalloc_server_status_section.cpp')
-rw-r--r--src/mongo/util/tcmalloc_server_status_section.cpp57
1 files changed, 7 insertions, 50 deletions
diff --git a/src/mongo/util/tcmalloc_server_status_section.cpp b/src/mongo/util/tcmalloc_server_status_section.cpp
index ebd02e64a73..04cec0908b6 100644
--- a/src/mongo/util/tcmalloc_server_status_section.cpp
+++ b/src/mongo/util/tcmalloc_server_status_section.cpp
@@ -43,62 +43,19 @@
#include "mongo/db/server_parameters.h"
#include "mongo/db/service_context.h"
#include "mongo/transport/service_entry_point.h"
-#include "mongo/transport/thread_idle_callback.h"
#include "mongo/util/log.h"
namespace mongo {
namespace {
-// If many clients are used, the per-thread caches become smaller and chances of
-// rebalancing of free space during critical sections increases. In such situations,
-// it is better to release memory when it is likely the thread will be blocked for
-// a long time.
-const int kManyClients = 40;
-MONGO_COMPILER_VARIABLE_UNUSED stdx::mutex tcmallocCleanupLock;
-
-MONGO_EXPORT_SERVER_PARAMETER(tcmallocEnableMarkThreadTemporarilyIdle, bool, false);
-
-/**
- * Callback to allow TCMalloc to release freed memory to the central list at
- * favorable times. Ideally would do some milder cleanup or scavenge...
- */
-void threadStateChange() {
-
- if (!tcmallocEnableMarkThreadTemporarilyIdle.load()) {
- return;
- }
-
- if (getGlobalServiceContext()->getServiceEntryPoint()->numOpenSessions() <= kManyClients)
- return;
-
-#if MONGO_HAVE_GPERFTOOLS_GET_THREAD_CACHE_SIZE
- size_t threadCacheSizeBytes = MallocExtension::instance()->GetThreadCacheSize();
-
- static const size_t kMaxThreadCacheSizeBytes = 0x10000;
- if (threadCacheSizeBytes < kMaxThreadCacheSizeBytes) {
- // This number was chosen a bit magically.
- // At 1000 threads and the current (64mb) thread local cache size, we're "full".
- // So we may want this number to scale with the number of current clients.
- return;
- }
-
- LOG(1) << "thread over memory limit, cleaning up, current: " << (threadCacheSizeBytes / 1024)
- << "k";
-
- // We synchronize as the tcmalloc central list uses a spinlock, and we can cause a really
- // terrible runaway if we're not careful.
- stdx::lock_guard<stdx::mutex> lk(tcmallocCleanupLock);
-#endif
- MallocExtension::instance()->MarkThreadTemporarilyIdle();
-}
-
-// Register threadStateChange callback
-MONGO_INITIALIZER(TCMallocThreadIdleListener)(InitializerContext*) {
- if (!RUNNING_ON_VALGRIND)
- registerThreadIdleCallback(&threadStateChange);
- return Status::OK();
-}
+MONGO_EXPORT_SERVER_PARAMETER(tcmallocEnableMarkThreadTemporarilyIdle, bool, false)
+ ->withValidator([](const bool& potentialNewValue) {
+ return Status(ErrorCodes::BadValue,
+ "tcmallocEnableMarkThreadTemporarilyIdle has been removed. Setting this "
+ "parameter has no effect and it will be removed in a future version of "
+ "MongoDB.");
+ });
class TCMallocServerStatusSection : public ServerStatusSection {
public: