Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sleeping in Bencher::with_inputs affects benchmark time #55

Closed
OliverKillane opened this issue May 14, 2024 · 5 comments
Closed

Sleeping in Bencher::with_inputs affects benchmark time #55

OliverKillane opened this issue May 14, 2024 · 5 comments
Labels
bug Something isn't working

Comments

@OliverKillane
Copy link
Contributor

OliverKillane commented May 14, 2024

Description

with_inputs affects the benchmark time with sleep, the documentation specifies it does not.

Replicate

Example here

@nvzqz
Copy link
Owner

nvzqz commented May 14, 2024

Your benchmarks are measuring dropping Vec inputs because they use bench_values. Switching to bench_refs fixes the timings by deferring drop until after the loop.

Not sure why sleeping affects timings though.

@OliverKillane
Copy link
Contributor Author

D'oh, forgot the drop. That fixes it for me - much appreciated!

Is the with_sleep worth pursuing, or should we close this issue?

@nvzqz nvzqz added the bug Something isn't working label May 14, 2024
@nvzqz
Copy link
Owner

nvzqz commented May 14, 2024

I think sleeping affecting timing is a legit issue.

@nvzqz nvzqz changed the title BUG: with_inputs affects benchmark time Sleeping in Bencher::with_inputs affects benchmark time May 14, 2024
@OliverKillane
Copy link
Contributor Author

I have fixed the linked example, with a simpler mm_pause for busy sleeping. I need to sleep now.

@nvzqz
Copy link
Owner

nvzqz commented May 15, 2024

I see the issue here. You're setting max_time = 0.1 which also takes into account input generation time.

Internally it's hitting max_time because the benchmark loop needs more iterations but then with_inputs spends more of the time budget. This causes with_sleep to only have enough time to record a single sample of 1, 8, or 64 iterations. To get accurate timings it needs to record multiple samples over more iterations.

Setting DIVAN_SAMPLE_SIZE=100 (instead of dynamic sample size) shows that sleeping in input generation doesn't affect timings.

@nvzqz nvzqz closed this as completed May 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants