Skip to content

fix(warmup): honor per-benchmark warmup without MinTime - #2339

Open
tuna4ll wants to merge 2 commits into
google:mainfrom
tuna4ll:fix/per-benchmark-warmup
Open

tuna4ll wants to merge 2 commits into
google:mainfrom
tuna4ll:fix/per-benchmark-warmup

Conversation

@tuna4ll

@tuna4ll tuna4ll commented Oct 16, 2026

Copy link
Copy Markdown
Contributor

Fixed a bug where MinWarmUpTime() didn't work unless MinTime() was also set.

The fix allows benchmarks to use their own warmup time without requiring MinTime(), while keeping the existing global warmup and dry-run behavior.

I also added six tests to cover different warmup settings.

Testing:

  • Both regression tests failed before the fix and passed afterward.
  • All six tests pass in Debug and Release.
  • Full test suite: 88/88 passed in both builds.
  • Tests also passed with shuffled runs.

Assembly tests were skipped because they already failed on the original code with GCC 16.2.1.

No API or ABI changes.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Code Review

This pull request simplifies the initialization of min_warmup_time in BenchmarkRunner by removing the check on b.min_time(), allowing warmup time to be configured independently of the minimum benchmark run time. It also adds a comprehensive suite of unit tests in test/benchmark_warmup_gtest.cc to verify warmup behavior under various configurations (such as local/global warmup overrides and dry runs) and registers this new test in test/CMakeLists.txt. There are no review comments to address, and I have no additional feedback to provide.

@LebedevRI

Copy link
Copy Markdown
Collaborator

Hmm yeah, looking through #1399, it is not apparent to me why warmup should only be done when the benchmark iteself specifies its own min time.

@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.

Does this PR need an AI disclaimer?

@tuna4ll

tuna4ll commented Oct 16, 2026

Copy link
Copy Markdown
Contributor Author

Does this PR need an AI disclaimer?

Nope, I only wrote the PR description in Turkish and used an LLM to translate it into English.

Comment thread test/benchmark_warmup_gtest.cc Outdated
Comment on lines +8 to +12
namespace benchmark {

BM_DECLARE_bool(benchmark_dry_run);
BM_DECLARE_string(benchmark_min_time);
BM_DECLARE_double(benchmark_min_warmup_time);

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.

I think i'm not entirely happy with this testing strategy :(

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.

Could you elaborate on what concerns you about the testing strategy? I'd be happy to revise the tests accordingly.

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.

The entirety of this approach, i'm afraid. I don't like how this needs to open benchmark namespace.
There is no nice way to test this, the alternative is running the test in a subprocess...
IMHO this is the case where i'd be grudgingly okay with not having test coverage.

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.

Understood, thanks for clarifying it!

I will remove the tests and keep the PR focused on the fix itself.

@tuna4ll

tuna4ll commented Oct 16, 2026

Copy link
Copy Markdown
Contributor Author

I've removed the regression tests as suggested. Thanks for the feedback!

@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.

So i think this is fine. I can't understand why that condition was there,
the original PR does not seem to explain it.

@LebedevRI
LebedevRI requested a review from dmah42 October 16, 2026 21:25

This branch has not been deployed

No deployments
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