Skip to content

Commit

Permalink
Adapt SnoopPrecompile to work for new julia API.
Browse files Browse the repository at this point in the history
Starting in JuliaLang/julia#47615, we are
changing the API for snoopi_deep, to allow for thread safe snooping
in one thread while compiling in another.

This commit changes SnoopPrecompile to work with the new API if it's
available.
  • Loading branch information
vilterp authored and NHDaly committed Nov 22, 2022
1 parent ad792af commit d40b6eb
Showing 1 changed file with 22 additions and 9 deletions.
31 changes: 22 additions & 9 deletions SnoopPrecompile/src/SnoopPrecompile.jl
Original file line number Diff line number Diff line change
Expand Up @@ -59,16 +59,29 @@ macro precompile_all_calls(ex::Expr)
end
end
if have_inference_tracking
ex = quote
Core.Compiler.Timings.reset_timings()
Core.Compiler.__set_measure_typeinf(true)
try
$ex
finally
Core.Compiler.__set_measure_typeinf(false)
Core.Compiler.Timings.close_current_timer()
ex = if isdefined(Core.Compiler.Timings, :clear_and_fetch_timings)
# use new thread-safe timings API if it's available in this version of Julia
quote
Core.Compiler.__set_measure_typeinf(true)
try
$ex
finally
Core.Compiler.__set_measure_typeinf(false)
end
$SnoopPrecompile.precompile_roots(Core.Compiler.Timings.clear_and_fetch_timings())
end
else
quote
Core.Compiler.Timings.reset_timings()
Core.Compiler.__set_measure_typeinf(true)
try
$ex
finally
Core.Compiler.__set_measure_typeinf(false)
Core.Compiler.Timings.close_current_timer()
end
$SnoopPrecompile.precompile_roots(Core.Compiler.Timings._timings[1].children)
end
$SnoopPrecompile.precompile_roots(Core.Compiler.Timings._timings[1].children)
end
end
return esc(quote
Expand Down

0 comments on commit d40b6eb

Please sign in to comment.