Repository navigation
fix: report threads as 1 in State during single-threaded manager passes (fixes #1849) - #2324
ReturnKartikey wants to merge 1 commit into
Conversation
|
this was and remains a deliberate design choice. for profile and memory profiling we want to run a single thread only even if the benchmark is multithreaded. if you want to question the design choice let's have that discussion first. |
|
@dmah42 The problem is that during this pass, If we keep the single-thread design, would you prefer that |
|
oh yeah, that sounds like a clear bug in the state that we should fix. |
…es (fixes google#1849) In BenchmarkRunner::RunMemoryManager and BenchmarkRunner::RunProfilerManager, execution deliberately runs single-threaded with ThreadManager(1) and thread 0. However, State was constructed with the benchmark's configured thread count (b.threads()), causing state.threads() to report multiple threads despite only a single thread running. For multithreaded benchmarks and fixtures that synchronize or coordinate across state.threads() (such as barriers, latches, or SetUp/TearDown hooks), thread 0 hung waiting indefinitely for other threads that were never spawned. This patch updates BenchmarkInstance::Run, Setup, and Teardown to accept an optional thread_count override and passes thread_count = 1 during RunMemoryManager and RunProfilerManager passes so state.threads() correctly reflects the active single-threaded execution. Also adds a regression test in memory_manager_ordering_gtest.
3921bc2 to
2b36d89
Compare
|
Updated the PR as discussed! RunMemoryManager and RunProfilerManager remain single-threaded (ThreadManager(1)), and we now pass hread_count = 1 into State and Setup/Teardown during those passes so state.threads() accurately reports 1. Multithreaded fixtures using state.threads() for barrier synchronization now execute and complete cleanly without deadlocks. |
Fixes #1849
Summary of Changes
In BenchmarkRunner::RunMemoryManager and BenchmarkRunner::RunProfilerManager, execution deliberately runs single-threaded with ThreadManager(1) and thread 0.
However, �enchmark::State was previously constructed using �.threads() (the benchmark's configured thread count), causing state.threads() to report multiple threads despite only 1 thread being executed.
For multithreaded benchmarks or fixtures that synchronize across all threads (e.g. waiting for state.threads() workers via barriers, latches, or custom setup/teardown coordination), thread 0 hung indefinitely waiting for worker threads that were never spawned.
This patch:
Verification