diff options
author | Benety Goh <benety@mongodb.com> | 2021-10-19 19:05:06 -0400 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2021-10-26 19:11:54 +0000 |
commit | f495196558c2cff158a1bd61b919d99643c34546 (patch) | |
tree | 4caff471340c7a1a3c9fb8a4f72903cf700f2ff5 | |
parent | b279170319860b50baf7d93bf75f9b111e3ca0b4 (diff) | |
download | mongo-f495196558c2cff158a1bd61b919d99643c34546.tar.gz |
SERVER-60691 DConcurrencyTest benchmark sets locker using client observer
(cherry picked from commit 5550576ebdbb36135e97a5a4114874c92724c7a0)
-rw-r--r-- | src/mongo/db/concurrency/d_concurrency_bm.cpp | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/src/mongo/db/concurrency/d_concurrency_bm.cpp b/src/mongo/db/concurrency/d_concurrency_bm.cpp index f9c29b849e0..554903de4df 100644 --- a/src/mongo/db/concurrency/d_concurrency_bm.cpp +++ b/src/mongo/db/concurrency/d_concurrency_bm.cpp @@ -42,6 +42,28 @@ namespace { const int kMaxPerfThreads = 16; // max number of threads to use for lock perf +class LockerImplClientObserver : public ServiceContext::ClientObserver { +public: + LockerImplClientObserver() = default; + ~LockerImplClientObserver() = default; + + void onCreateClient(Client* client) final {} + + void onDestroyClient(Client* client) final {} + + void onCreateOperationContext(OperationContext* opCtx) override { + opCtx->setLockState(std::make_unique<LockerImpl>()); + } + + void onDestroyOperationContext(OperationContext* opCtx) final {} +}; + +const ServiceContext::ConstructorActionRegisterer clientObserverRegisterer{ + "DConcurrencyTestClientObserver", + [](ServiceContext* service) { + service->registerClientObserver(std::make_unique<LockerImplClientObserver>()); + }, + [](ServiceContext* serviceContext) {}}; class DConcurrencyTest : public benchmark::Fixture { public: @@ -55,7 +77,6 @@ public: auto client = getGlobalServiceContext()->makeClient(str::stream() << "test client for thread " << i); auto opCtx = client->makeOperationContext(); - client->swapLockState(std::make_unique<LockerImpl>()); clients.emplace_back(std::move(client), std::move(opCtx)); } } |