Exclude setup/teardown from the MemoryManager measurement window (#2149) - #2276
Merged
dmah42 merged 1 commit intoAug 3, 2026
Merged
Conversation
dmah42
reviewed
Aug 3, 2026
| std::unique_ptr<internal::ThreadManager> manager; | ||
| manager.reset(new internal::ThreadManager(1)); | ||
| b.Setup(); | ||
| MemoryManager::Result memory_result; |
Member
There was a problem hiding this comment.
why have you moved the declaration of the result?
dmah42
reviewed
Aug 3, 2026
| MemoryManager::Result BenchmarkRunner::RunMemoryManager( | ||
| IterationCount memory_iterations) { | ||
| memory_manager->Start(); | ||
| // Set up the thread manager and run the user's Setup() outside the |
Member
There was a problem hiding this comment.
is this a useful comment or just the AI spewing the decisions its made?
dmah42
reviewed
Aug 3, 2026
…gle#2149) RunMemoryManager() opened the MemoryManager window before allocating the ThreadManager and running the per-benchmark Setup(), and closed it after Teardown(). Everything the library and the fixture allocate around the benchmark was therefore attributed to the benchmark itself, so an exact allocation count was impossible to obtain. Move Start()/Stop() to bracket only RunInThread(), which is the same region the timers cover. Setup()/Teardown() already run outside the timed region, so this makes the memory window consistent with the time window. Add memory_manager_ordering_gtest, which registers a MemoryManager that records whether the window is open and asserts the fixture callbacks never observe it as open. It fails on the previous ordering ("Teardown ran inside the MemoryManager Start/Stop window") and passes with this change.
devtejasx
force-pushed
the
fix-memory-manager-measurement-window
branch
from
August 3, 2026 09:45
58c470a to
32d4edd
Compare
Contributor
Author
|
All three addressed; the runner change is now a four-line move.
|
dmah42
approved these changes
Aug 3, 2026
Member
|
thanks |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
RunMemoryManager() opened the MemoryManager window before allocating the ThreadManager and running the per-benchmark Setup(), and closed it after Teardown(). Everything the library and the fixture allocate around the benchmark was therefore attributed to the benchmark itself, so an exact allocation count was impossible to obtain.
Move Start()/Stop() to bracket only RunInThread(), which is the same region the timers cover. Setup()/Teardown() already run outside the timed region, so this makes the memory window consistent with the time window.
Add memory_manager_ordering_gtest, which registers a MemoryManager that records whether the window is open and asserts the fixture callbacks never observe it as open. It fails on the previous ordering ("Teardown ran inside the MemoryManager Start/Stop window") and passes with this change.
Per AGENTS.md: AI-assisted — the patch was drafted with AI assistance
(Claude) and then reviewed, tested, and understood by me. I take full
responsibility for it.