diff options
author | Geert Bosch <geert@mongodb.com> | 2015-04-10 13:05:05 -0400 |
---|---|---|
committer | Geert Bosch <geert@mongodb.com> | 2015-04-10 15:09:43 -0400 |
commit | 8e6e1d78c4c170384e024747737c94542f9f60d3 (patch) | |
tree | 0ffa490345e929cba1472685dd8f712afa2fe158 /src/mongo/db/concurrency/lock_state.cpp | |
parent | 174b36483d16bb2bdf2329ed5372710390ac7719 (diff) | |
download | mongo-8e6e1d78c4c170384e024747737c94542f9f60d3.tar.gz |
SERVER-15901: Periodically cleanup unused lock heads
Diffstat (limited to 'src/mongo/db/concurrency/lock_state.cpp')
-rw-r--r-- | src/mongo/db/concurrency/lock_state.cpp | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/src/mongo/db/concurrency/lock_state.cpp b/src/mongo/db/concurrency/lock_state.cpp index 2ceb854be1c..6d3aa4f6467 100644 --- a/src/mongo/db/concurrency/lock_state.cpp +++ b/src/mongo/db/concurrency/lock_state.cpp @@ -35,6 +35,7 @@ #include "mongo/db/service_context.h" #include "mongo/db/namespace_string.h" #include "mongo/platform/compiler.h" +#include "mongo/util/background.h" #include "mongo/util/concurrency/synchronization.h" #include "mongo/util/debug_util.h" #include "mongo/util/log.h" @@ -867,6 +868,26 @@ namespace { } +namespace { + /** + * Periodically purges unused lock buckets. The first time the lock is used again after + * cleanup it needs to be allocated, and similarly, every first use by a client for an intent + * mode may need to create a partitioned lock head. Cleanup is done roughtly once a minute. + */ + class UnusedLockCleaner : PeriodicTask { + public: + std::string taskName() const { + return "UnusedLockCleaner"; + } + + void taskDoWork() { + LOG(2) << "cleaning up unused lock buckets of the global lock manager"; + getGlobalLockManager()->cleanupUnusedLocks(); + } + } unusedLockCleaner; +} // namespace + + // // Standalone functions // |