-
Notifications
You must be signed in to change notification settings - Fork 102
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
warm up at the beginning of every measurement #330
Conversation
@gdalle I think this one is ready for review! |
Thanks @willow-ahrens! I'm a bit swamped at the moment but I haven't forgotten this, it's on my to-do list and then the 2.0 will probably follow |
@test p.evals == 1 | ||
@test p.gctrial == false | ||
@test p.gcsample == false | ||
@test (@belapsed needs_warm() seconds = 1) < 1 |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
Looks good to me |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
@gdalle Hi there! Given this is on the release milestone and has an approving review, I'm sending a friendly ping your way. Thanks for all your work on this repo 😊 |
Hi @willow-ahrens and thanks for the ping.
However, I do wanna point out that this would affect the behavior of mutating functions, i.e. those for which we set |
Thanks for the prompt response! I believe not warming up is a correctness issue, especially since the package usually warms up but unexpectedly doesn't in certain circumstances. This is an important package in the Julia ecosystem so I'd like to see some fix to the issue. Perhaps we can ask someone else for help reviewing? To answer your specific question:
When we call |
My issue is the case where the function destroys its input, so that only one evaluation is possible. Consider the following example: julia> using BenchmarkTools
julia> @benchmark pop!(x) setup=(x=[0]) evals=1
BenchmarkTools.Trial: 10000 samples with 1 evaluation.
Range (min … max): 34.000 ns … 425.000 ns ┊ GC (min … max): 0.00% … 0.00%
Time (median): 42.000 ns ┊ GC (median): 0.00%
Time (mean ± σ): 42.534 ns ± 7.141 ns ┊ GC (mean ± σ): 0.00% ± 0.00%
▃ ▄▅ ▆ ▇▇ █ ▇ ▅▄ ▃ ▁▁ ▁ ▁ ▁ ▂
▄█▁█▁██▁█▁██▁█▁█▁██▁█▁██▁█▁▇▁▆▆▁▄▁▆▇▁█▁▇▁██▁█▁██▁█▁▇▁▇▇▁▇▁▇▆ █
34 ns Histogram: log(frequency) by time 69 ns <
Memory estimate: 0 bytes, allocs estimate: 0. Until my PR #318 this used to error. With BenchmarkTools 1.4 it doesn't. With automatic warmup... it would again? I agree this is a rather niche case, but there were 4 issues closed by that PR so I assume people have run into it |
Your example works with this pr, as we run a full sample to warmup (which includes the setup and teardown) not a single eval. As for the part about this being a breaking change, would not removing Thanks for all your work on this package. |
I understand your concern. However, I have tested this PR with your function and it does not error:
This is because my "warmup" step just re-uses the existing BenchmarkTools It's somewhat opaque because there is metaprogramming involved, but you can see BenchmarkTools.jl/src/execution.jl Line 548 in c655edb
In BenchmarkTools.jl, we can understand the current
This PR is a petition to change the last three lines to:
|
@Zentrik I agree, we don't need to remove warmup. We may want to issue a deprecation though? Are deprecations breaking? |
Thanks for the clarifications, I had missed the setup phase in |
According to SciML ColPrac they are not https://docs.sciml.ai/ColPrac/stable/#Incrementing-the-package-version |
Okay, looks like this is all set then! |
Cool, I'll try and test this out tomorrow. |
It may be difficult to know that it has been called recently. The reason we always warm up is that running other code in between makes the benchmark go cold. |
I figure for |
@gdalle okay, I think we're ready for your review, whenever you find time. Thanks for your help with this! |
@Zentrik I think that to maintain semantics with how |
I'm not sure this pr currently changes the semantic of |
@gdalle would it be breaking to add a boolean |
Neither of those is breaking as long as they don't change the semantics of existing code that does not use them |
In that case, @Zentrik if you want to give it a go adding a boolean to the run kwargs for warmup, we could use that here to maintain semantics in bprofile. |
Okay, I added a |
gotta love the commit messages ;) ping me when this is ready! |
@gdalle this one's ready! it's passing tests, but the icon is fail because the changes only reached 90% coverage rather than 91%. |
Thanks, sorry I've just been a bit busy and hadn't got around to this. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the contribution! I think most of the remarks stem from my own lack of understanding, but once we fix that it looks good to go
@gdalle I responded to your comments. I don't think anything needs to change, but I'm happy to change anything you would like, just let me know. |
Sorry this has stalled, trying to get it merged and release this week |
Thank you so much for your work and patience, and sorry for the delay. This is a really important change and I reviewed it to the best of my ability. |
fixes #291