-
Notifications
You must be signed in to change notification settings - Fork 97
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
Add experimental support for customisable benchmarking #347
base: master
Are you sure you want to change the base?
Conversation
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as outdated.
This comment was marked as outdated.
We might need to set up Buildkite CI on this repo. @vchuravy @staticfloat |
f27a5de
to
bbfb733
Compare
This comment was marked as outdated.
This comment was marked as outdated.
cfa2cef
to
fb0b711
Compare
b1bc53c
to
468b607
Compare
I'd like to mark this feature as experimental or something to that effect so that we can make breaking changes to it without making a breaking change to BenchmarkTools. I'll make a separate pr removing Buildkite. I've moved the LinuxPerf stuff to https://github.com/Zentrik/BenchmarkToolsPlusLinuxPerf.jl. I do have a version of bprofile_setup_prehook(_) = Profile.check_init()
function bprofile_prehook()
results = samplefunc_prehook()
status = ccall(:jl_profile_start_timer, Cint, ())
if status < 0
error(Profile.error_codes[status])
end
return results
end
function bprofile_posthook()
Profile.stop_timer()
return samplefunc_posthook()
end
# """
# @bprofile expression [other parameters...]
# Run `@benchmark` while profiling. This is similar to
# @profile @benchmark expression [other parameters...]
# but the profiling is applied only to the main
# execution (after compilation and tuning).
# The profile buffer is cleared prior to execution.
# View the profile results with `Profile.print(...)`.
# See the profiling section of the Julia manual for more
# information.
# """
macro bprofile(args...)
_, params = prunekwargs(args...)
if !haskw(args, :gctrial)
args = (args..., Expr(:kw, :gctrial, false))
end
if !haskw(args, :gcsample)
args = (args..., Expr(:kw, :gcsample, false))
end
tmp = gensym()
return esc(
quote
local $tmp = $BenchmarkTools.@benchmarkable $(args...)
$(
if hasevals(params)
:(run(
$tmp, $BenchmarkTools.Parameters($tmp.params; evals=1); warmup=false
))
else
:($BenchmarkTools.tune!($tmp))
end
)
$BenchmarkTools.Profile.stop_timer()
$BenchmarkTools.Profile.clear()
$BenchmarkTools.run(
$tmp;
setup_prehook=$BenchmarkTools.bprofile_setup_prehook,
prehook=$BenchmarkTools.bprofile_prehook,
posthook=$BenchmarkTools.bprofile_posthook,
sample_result=$BenchmarkTools.samplefunc_sample_result,
enable_customisable_func=:ALL,
run_customisable_func_only=true,
)
end,
)
end |
This should theoretically allow FunctionWrappers or callable structs to be used, though serialization may be an issue.
Replaces #325 (closes #325)
This pr adds the ability to run a custom benchmarking function which has hooks to inject in custom functions. The current design supports running
perf
on a benchmark (see https://github.com/Zentrik/BenchmarkToolsPlusLinuxPerf.jl) and profiling benchmarks (excluding the setup, teardown and gcscrub which the currentbprofile
includes).