Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions base/Base.jl
Original file line number Diff line number Diff line change
Expand Up @@ -596,6 +596,8 @@ function __init__()
ccall(:jl_set_peek_cond, Cvoid, (Ptr{Cvoid},), PROFILE_PRINT_COND[].handle)
errormonitor(Threads.@spawn(profile_printing_listener()))
end
# Prevent spawned Julia process from getting stuck waiting on Tracy to connect.
delete!(ENV, "JULIA_WAIT_FOR_TRACY")
nothing
end

Expand Down
1 change: 0 additions & 1 deletion base/loading.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2141,7 +2141,6 @@ function create_expr_cache(pkg::PkgId, input::String, output::String, output_o::
$trace
-`,
"OPENBLAS_NUM_THREADS" => 1,
"JULIA_WAIT_FOR_TRACY" => nothing,
"JULIA_NUM_THREADS" => 1),
stderr = internal_stderr, stdout = internal_stdout),
"w", stdout)
Expand Down
13 changes: 13 additions & 0 deletions doc/src/devdocs/external_profilers.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,19 @@ JULIA_WAIT_FOR_TRACY=1 ./julia -e '...'

The environment variable ensures that Julia waits until it has successfully connected to the Tracy profiler before continuing execution. Afterward, use the Tracy profiler UI, click `Connect`, and Julia execution should resume and profiling should start.

### Profiling package precompilation with Tracy

To profile a package precompilation process it is easiest to explicitly call into `Base.compilecache` with the package you want to precompile:

```julia
pkg = Base.identify_package("SparseArrays")
withenv("JULIA_WAIT_FOR_TRACY" => 1, "TRACY_PORT" => 9001) do
Base.compilecache(pkg)
end
```

Here, we use a custom port for tracy which makes it easier to find the correct client in the Tracy UI to connect to.

### Adding metadata to zones

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.
Expand Down