File tree Expand file tree Collapse file tree 3 files changed +14
-24
lines changed
cloud/filestore/libs/storage/tablet/bench
contrib/ydb/library/actors/util Expand file tree Collapse file tree 3 files changed +14
-24
lines changed Original file line number Diff line number Diff line change 55
66#include < library/cpp/testing/benchmark/bench.h>
77
8+ #include < util/generic/singleton.h>
89#include < util/generic/vector.h>
910
10- #include < atomic>
1111#include < memory>
1212
1313using namespace NCloud ;
@@ -70,27 +70,10 @@ struct TTabletSetup
7070 }
7171};
7272
73- // Using a non-owning static variable because the test Actor System crashes
74- // during initialization.
75- // A singleton also doesn’t work because it causes
76- // other issues during deinitialization.
77- // A memory leak is the price we pay to prevent the program from crashing.
78- // This is acceptable because benchmarks are not run under sanitizers
79- std::atomic<TTabletSetup*> Tablet = nullptr ;
80-
8173TTabletSetup* GetOrCreateTablet ()
8274{
83- if (Tablet.load ()) {
84- return Tablet.load ();
85- }
86-
87- auto tmp = std::make_unique<TTabletSetup>();
88- TTabletSetup* expected = nullptr ;
89- if (!Tablet.compare_exchange_strong (expected, tmp.get ())) {
90- return Tablet.load ();
91- }
92-
93- return tmp.release ();
75+ constexpr ui64 Priority = Max<ui64>();
76+ return SingletonWithPriority<TTabletSetup, Priority>();
9477}
9578
9679} // namespace
Original file line number Diff line number Diff line change 11Y_BENCHMARK()
22
3- NO_SANITIZE()
3+ IF (SANITIZER_TYPE)
4+ TAG(ya :manual)
5+ ENDIF()
6+
47
58SRCS(
69 tablet_bench.cpp
Original file line number Diff line number Diff line change @@ -131,8 +131,9 @@ class TEnumProcessKey {
131131
132132 static size_t GetIndex (const EnumT key) {
133133 ui32 index = static_cast <ui32>(key);
134- Y_ABORT_UNLESS (index < Enum2Index.size ());
135- return Enum2Index[index];
134+ const auto & enum2Index = Singleton<TEnum2Index>()->Enum2Index ;
135+ Y_ABORT_UNLESS (index < enum2Index.size ());
136+ return enum2Index[index];
136137 }
137138
138139private:
@@ -153,5 +154,8 @@ class TEnumProcessKey {
153154 return enum2Index;
154155 }
155156
156- inline static TVector<size_t > Enum2Index = RegisterAll();
157+ struct TEnum2Index
158+ {
159+ TVector<size_t > Enum2Index = RegisterAll();
160+ };
157161};
You can’t perform that action at this time.
0 commit comments