-
Notifications
You must be signed in to change notification settings - Fork 104
Closed
Labels
Description
It appears tune! does not execute setup before every run, leading to errors in certain cases. See below for a MWE:
using BenchmarkTools
function f!(x::AbstractVector)
length(x) == 2 || error("setup not correctly executed")
push!(x, randn())
endThen @benchmarkable works:
b = @benchmarkable f!(y) setup=(y=randn(2))
run(b) # works
BenchmarkTools.Trial: 10000 samples with 1 evaluation.
Range (min … max): 66.000 ns … 32.197 μs ┊ GC (min … max): 0.00% … 0.00%
Time (median): 79.000 ns ┊ GC (median): 0.00%
Time (mean ± σ): 113.119 ns ± 446.383 ns ┊ GC (mean ± σ): 0.00% ± 0.00%
██▄▅▄▃▃▄▄▄▅▅▅▃▂▁ ▂
███████████████████████████▆▇▇▆▇▆▆▅▄▆▆▅▇▄▅▅▅▄▅▄▅▄▄▆▅▅▅▅▄▄▄▄▃▄ █
66 ns Histogram: log(frequency) by time 374 ns <
Memory estimate: 48 bytes, allocs estimate: 1.But neither @btime nor @benchmark do:
@btime f!(y) setup=(y=randn(2)) # errors
ERROR: setup not correctly executed
Stacktrace:
[1] error(s::String)
@ Base ./error.jl:33
[2] f!(x::Vector{Float64})
@ Main ~/Documents/SEA/UpdatableCholeskyFactorizations/doodles/benchmarktools_bug.jl:4
[3] var"##core#593"(y::Vector{Float64})
@ Main ~/.julia/packages/BenchmarkTools/uq9zP/src/execution.jl:479
[4] var"##sample#594"(__params::BenchmarkTools.Parameters)
@ Main ~/.julia/packages/BenchmarkTools/uq9zP/src/execution.jl:487
[5] _lineartrial(b::BenchmarkTools.Benchmark, p::BenchmarkTools.Parameters; maxevals::Int64, kwargs::Base.Iterators.Pairs{Union{}, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
@ BenchmarkTools ~/.julia/packages/BenchmarkTools/uq9zP/src/execution.jl:160
[6] _lineartrial(b::BenchmarkTools.Benchmark, p::BenchmarkTools.Parameters)
@ BenchmarkTools ~/.julia/packages/BenchmarkTools/uq9zP/src/execution.jl:152
[7] #invokelatest#2
@ ./essentials.jl:708 [inlined]
[8] invokelatest
@ ./essentials.jl:706 [inlined]
[9] #lineartrial#46
@ ~/.julia/packages/BenchmarkTools/uq9zP/src/execution.jl:34 [inlined]
[10] lineartrial
@ ~/.julia/packages/BenchmarkTools/uq9zP/src/execution.jl:34 [inlined]
[11] tune!(b::BenchmarkTools.Benchmark, p::BenchmarkTools.Parameters; progressid::Nothing, nleaves::Float64, ndone::Float64, verbose::Bool, pad::String, kwargs::Base.Iterators.Pairs{Union{}, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
@ BenchmarkTools ~/.julia/packages/BenchmarkTools/uq9zP/src/execution.jl:250
[12] tune! (repeats 2 times)
@ ~/.julia/packages/BenchmarkTools/uq9zP/src/execution.jl:249 [inlined]
[13] top-level scope
@ ~/.julia/packages/BenchmarkTools/uq9zP/src/execution.jl:566@benchmark yields a similar stack trace, leading me to believe that tune! does not call setup in subsequent runs.
Reactions are currently unavailable