@@ -5,7 +5,8 @@ import Profile
55import PProf
66
77using FlameGraphs
8- using SnoopCompile: InferenceTimingNode
8+ using SnoopCompile
9+ import SnoopCompileCore
910
1011using Serialization: serialize
1112
@@ -249,19 +250,17 @@ end # if isdefined
249250# ## Type Inference
250251# ##
251252
253+ # WARNING: This is not thread-safe unless your julia has merged
254+ # https://github.com/JuliaLang/julia/pull/47615.
252255function typeinf_start_endpoint (req:: HTTP.Request )
253- Core . Compiler . __set_measure_typeinf ( true )
256+ SnoopCompileCore . start_snoopi_deep ( )
254257 return HTTP. Response (200 , " Type inference profiling started." )
255258end
256259
257260function typeinf_stop_endpoint (req:: HTTP.Request )
258- Core. Compiler. __set_measure_typeinf (true )
259- timings = if isdefined (Core. Compiler. Timings, :clear_and_fetch_timings )
260- # TODO : make a root node out of this
261- Core. Compiler. Timings. clear_and_fetch_timings ()
262- else
263- InferenceTimingNode (Core. Compiler. Timings. _timings[1 ])
264- end
261+ SnoopCompileCore. stop_snoopi_deep ()
262+ timings = SnoopCompileCore. finish_snoopi_deep ()
263+
265264 flame_graph = flamegraph (timings)
266265 prof_name = tempname ()
267266 PProf. pprof (flame_graph; out= prof_name, web= false )
@@ -310,7 +309,7 @@ function __init__()
310309 precompile (_start_alloc_profile, (Float64,)) || error (" precompilation of package functions is not supposed to fail" )
311310 precompile (_stop_alloc_profile, ()) || error (" precompilation of package functions is not supposed to fail" )
312311 end
313-
312+
314313 precompile (typeinf_start_endpoint, (HTTP. Request,)) || error (" precompilation of package functions is not supposed to fail" )
315314 precompile (typeinf_stop_endpoint, (HTTP. Request,)) || error (" precompilation of package functions is not supposed to fail" )
316315end
0 commit comments