You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
precompilation: sample precompile workers with the runtime profiler
Most of a package's precompilation happens in a worker process that the driver
spawns, so profiling the session that called `Pkg.precompile()` shows the driver
waiting on its children and nothing about where the time went. Give the workers a
way to sample themselves.
`precompilepkgs` gains a `profile` keyword, taking `true` for every package or a
name or a list of names, and `profile_dir` for where the dumps land. The same is
available through `JULIA_PRECOMPILE_PROFILE` for precompilation started some
other way, such as by loading a package for the first time.
A selected worker starts the runtime's sampling profiler before it loads its
dependencies and dumps once its image has been written, so the profile covers
dependency loading, lowering, inference, code generation and image generation. It
writes the raw sample buffer alongside the stack frames its instruction pointers
resolve to, since a pointer can only be resolved by the process that recorded it.
`contrib/read_precompile_profile.jl` turns the pair back into the arguments that
`Profile.print` and the profile viewer packages take.
The worker side uses only `ccall` and `Base.StackTraces` on purpose: loading
Profile there would put it in the output image's dependency list.
Assisted-by: Claude Code (Fable 5.1)
Claude-Session: https://claude.ai/code/session_019BZkT3Ky7B3kq9xPiXLYVU
Copy file name to clipboardExpand all lines: doc/src/devdocs/external_profilers.md
+2Lines changed: 2 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -89,6 +89,8 @@ end
89
89
90
90
Here, we use a custom port for tracy which makes it easier to find the correct client in the Tracy UI to connect to.
91
91
92
+
For sampled stack traces of the same worker processes, rather than the zones described here, see [Profiling package precompilation](@ref).
93
+
92
94
### Adding metadata to zones
93
95
94
96
The various `jl_timing_show_*` and `jl_timing_printf` functions can be used to attach a string (or strings) to a zone. For example, the trace zone for inference shows the method instance that is being inferred.
0 commit comments