Skip to content

Commit c65e4fe

Browse files
authored
Fix tsan race in actor quicksort benchmark (#11664)
1 parent e42984e commit c65e4fe

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

ydb/library/actors/core/ut/benchmark_ut.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -102,15 +102,17 @@ Y_UNIT_TEST_SUITE(ActorSystemBenchmark) {
102102
auto [leftParams, rightParams] = SplitParameters(params, newRight, newLeft);
103103

104104
bool ranAsync = false;
105+
bool wantSplit = newLeft < params.Right && params.Left < newRight;
105106

106107
if (newLeft < params.Right) {
107-
ranAsync = TryRunAsync(rightParams);
108-
if (ranAsync) {
108+
ranAsync = wantSplit && TryRunAsync(rightParams);
109+
if (!ranAsync) {
109110
Sort(rightParams);
110111
}
111112
}
112113
if (params.Left < newRight) {
113-
if (!ranAsync && !TryRunAsync(leftParams)) {
114+
ranAsync = wantSplit && !ranAsync && TryRunAsync(leftParams);
115+
if (!ranAsync) {
114116
Sort(leftParams);
115117
}
116118
}
@@ -145,7 +147,7 @@ Y_UNIT_TEST_SUITE(ActorSystemBenchmark) {
145147
using TParameters = TQuickSortEngine::TParameters;
146148
struct TThreadPoolParameters {
147149
const ui32 ThreadsLimit = 0;
148-
std::atomic<ui32> ThreadsUsed = 0;
150+
std::atomic<ui32> ThreadsUsed;
149151
TThreadPool& ThreadPool;
150152

151153
TThreadPoolParameters(ui32 threadsLimit, ui32 threadsUsed, TThreadPool &threadPool)

0 commit comments

Comments
 (0)