Let WaitIfUpstreamIdle spin long enough to stay saturated by load_tester

This commit is contained in:
2025-08-26 15:37:04 -04:00
parent 6dbf29d1e1
commit 6e48a0ff9a
4 changed files with 24 additions and 11 deletions

View File

@@ -114,10 +114,17 @@ uint32_t calculate_safe_len(
// Empty - busy wait
} else if constexpr (wait_strategy ==
WaitStrategy::WaitIfUpstreamIdle) {
auto push = pushes.load(std::memory_order_relaxed);
if (push == thread.local_pops) {
pushes.wait(push, std::memory_order_relaxed);
// We're allowed to spin as long as we eventually go to 0% cpu
// usage on idle
uint32_t push;
for (int i = 0; i < 100000; ++i) {
push = pushes.load(std::memory_order_relaxed);
if (push != thread.local_pops) {
goto dont_wait;
}
}
pushes.wait(push, std::memory_order_relaxed);
dont_wait:;
} else {
static_assert(wait_strategy == WaitStrategy::WaitIfStageEmpty);
last_push.wait(thread.last_push_read[Is],