Skip to content

Report actual instead of requested iterations in memory results - #2322

Merged
LebedevRI merged 3 commits into
google:mainfrom
nicholasjng:push-oqskqzymwzkw
Oct 30, 2026
Merged

LebedevRI merged 3 commits into
google:mainfrom
nicholasjng:push-oqskqzymwzkw

Conversation

@nicholasjng

Copy link
Copy Markdown
Contributor

Previously, the run report contained the requested number of memory iterations. When using KeepRunningBatch with a batch size not dividing that number, the memory profiling overshoots, and additional iterations go unreported.

This change sets the number of iterations that were actually run in the memory manager as memory_result.memory_iterations, and adds a regression test exercising the overshooting path via KeepRunningBatch().


Found in experiments with KeepRunningBatch and memory profiling in mew.

disclaimer: I used AI for the creation of the unit test, reviewed it with the existing profiler_manager_iterations_test.cc as reference, liked what I saw.

@nicholasjng

nicholasjng commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor Author

I could make it a gtest instead, and use EXPECT_DOUBLE_EQ for allocs_per_iter there.

EDIT: converted to a gtest. Bazel needs no updates because of the file matching logic.

Comment thread src/benchmark_runner.cc
Comment thread src/benchmark_runner.cc
Comment thread src/benchmark_runner.cc Outdated

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please drop this argument then.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@LebedevRI LebedevRI left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, i see.
Can some of the explicit memory_iterations arguments be dropped then?

Previously, the run report contained the requested number of memory iterations.
When using `KeepRunningBatch` with a batch size not dividing that number, the
memory profiling overshoots, and additional iterations go unreported.

This change sets the number of iterations that were actually run in the memory
manager as `memory_result.memory_iterations`, and adds a regression test
exercising the overshooting path via `KeepRunningBatch()`.
The guard against division by zero stays in place in the `allocs_per_iter`
calculation, since memory_result.memory_iterations is initialized to zero,
and can be left zero in a skipped memory manager pass.

@LebedevRI LebedevRI left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LG, thank you!

@LebedevRI
LebedevRI merged commit 3251a25 into google:main Oct 30, 2026
104 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants