JuliaCI / JuliaCI/BenchmarkTools.jl
Benchmarked function is run one more time than specified
Nobody has claimed this yet.
- Dominant language
- Julia
- Stars
- 684
- Forks
- 107
- PR merge metrics
- No merged PRs in 30d
Description
Consider the following example:
first_run = false
function f()
global first_run
if !first_run; first_run = true; else sleep(1); end
println(time())
end
@benchmark f() evals=1 samples=1
which outputs
1.734518515199018e9
1.734518516201369e9
BenchmarkTools.Trial: 1 sample with 1 evaluation.
Single result which took 1.002 s (0.00% GC) to evaluate,
with a memory estimate of 624 bytes, over 11 allocations.
It seems that `f` is run an additional time before the actual sample is taken. This seems not to be documented. I wonder if this is to even compilation time out. If yes, where do I find information about that? In particular, is it possible to skip this, or trigger compilation with a cheaper instance?
Run on Julia 1.10 with BenchmarkTools v1.5.0.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the @benchmark entry point and the evals=1, samples=1 configuration shown in the report. Reproduce the extra invocation on Julia 1.10 with BenchmarkTools v1.5.0, then trace how setup, compilation, and sampling are handled. Done means explaining the additional run and documenting or exposing the relevant behavior, including whether it can be skipped.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- julia
- Domain
- performance
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100