diff options
author | Benety Goh <benety@mongodb.com> | 2021-10-19 19:04:54 -0400 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2021-10-28 22:28:41 +0000 |
commit | 777d1dbd1d75ea689563b01059b16854051c74da (patch) | |
tree | 9a561dc555866381d44f22d0942b88ffdfec2165 | |
parent | 027f2c260a49a14381846b288378eaadd4b8d349 (diff) | |
download | mongo-777d1dbd1d75ea689563b01059b16854051c74da.tar.gz |
SERVER-60691 remove global service context initialization from benchmark_main
(cherry picked from commit fbc1eb46306113acd5d44a2835b0dcd4257eb56b)
-rw-r--r-- | src/mongo/db/concurrency/d_concurrency_bm.cpp | 6 | ||||
-rw-r--r-- | src/mongo/unittest/SConscript | 4 | ||||
-rw-r--r-- | src/mongo/unittest/benchmark_main.cpp | 2 |
3 files changed, 9 insertions, 3 deletions
diff --git a/src/mongo/db/concurrency/d_concurrency_bm.cpp b/src/mongo/db/concurrency/d_concurrency_bm.cpp index 554903de4df..dd9b3223081 100644 --- a/src/mongo/db/concurrency/d_concurrency_bm.cpp +++ b/src/mongo/db/concurrency/d_concurrency_bm.cpp @@ -31,6 +31,7 @@ #include "mongo/platform/basic.h" #include <benchmark/benchmark.h> +#include "mongo/base/init.h" #include "mongo/db/concurrency/d_concurrency.h" #include "mongo/db/concurrency/lock_manager_test_help.h" #include "mongo/db/storage/recovery_unit_noop.h" @@ -42,6 +43,11 @@ namespace { const int kMaxPerfThreads = 16; // max number of threads to use for lock perf +MONGO_INITIALIZER_GENERAL(DConcurrencyTestServiceContext, ("DConcurrencyTestClientObserver"), ()) +(InitializerContext* context) { + setGlobalServiceContext(ServiceContext::make()); +} + class LockerImplClientObserver : public ServiceContext::ClientObserver { public: LockerImplClientObserver() = default; diff --git a/src/mongo/unittest/SConscript b/src/mongo/unittest/SConscript index defb9b2afa7..3c015a5fc40 100644 --- a/src/mongo/unittest/SConscript +++ b/src/mongo/unittest/SConscript @@ -77,8 +77,10 @@ bmEnv.Library( 'benchmark_main.cpp' ], LIBDEPS=[ + # benchmark_main must not be made to depend on additional libraries. + # Additional requirements should be handled by the benchmark itself. + # Examples can be found in fail_point_bm and commands_bm. See SERVER-60691. '$BUILD_DIR/mongo/base', - '$BUILD_DIR/mongo/db/service_context', '$BUILD_DIR/third_party/shim_benchmark', ], AIB_COMPONENT='benchmarks' diff --git a/src/mongo/unittest/benchmark_main.cpp b/src/mongo/unittest/benchmark_main.cpp index 9e76cbff81a..060ab6f0f60 100644 --- a/src/mongo/unittest/benchmark_main.cpp +++ b/src/mongo/unittest/benchmark_main.cpp @@ -35,7 +35,6 @@ #include "mongo/base/initializer.h" #include "mongo/config.h" -#include "mongo/db/service_context.h" #include "mongo/logv2/log.h" #include "mongo/util/signal_handlers_synchronous.h" @@ -45,7 +44,6 @@ int main(int argc, char** argv) { ::mongo::setupSynchronousSignalHandlers(); ::mongo::runGlobalInitializersOrDie(std::vector<std::string>(argv, argv + argc)); - ::mongo::setGlobalServiceContext(::mongo::ServiceContext::make()); // Copied from the BENCHMARK_MAIN macro. ::benchmark::Initialize(&argc, argv); |