Skip to content

Commit c2ec74d

Browse files
committed
Show the metadata tags in the flamegraph UI by default
1 parent 2a789ae commit c2ec74d

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

src/PProf.jl

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ using Base.StackTraces: StackFrame
4848
web = true, webhost = "localhost", webport = 57599,
4949
out = "profile.pb.gz", from_c = true, full_signatures = true, drop_frames = "",
5050
keep_frames = "", ui_relative_percentages = true, sampling_delay = nothing,
51+
tagroot = "taskid,threadid"
5152
)
5253
pprof(FlameGraphs.flamegraph(); kwargs...)
5354
@@ -78,6 +79,14 @@ You can also use `PProf.refresh(file="...")` to open a new file in the server.
7879
- `from_c::Bool`: If `false`, exclude frames that come from from_c. Defaults to `true`.
7980
- `full_signatures::Bool`: If `true`, methods are printed as signatures with full argument
8081
types. If `false`, as only names. E.g. `eval(::Module, ::Any)` vs `eval`.
82+
- `tagroot`: Set which metadata tags you want to turn into root frames for the profile. This
83+
is used to view the metadata tags in the Flamegraph view. This should be a
84+
comma-separated string, chosing from the following metadata options:
85+
- `taskid`
86+
- `threadid`
87+
- `thread_sleeping`
88+
- `cycle_clock`
89+
Defaults to `"taskid,threadid"`, grouping by taskid then threadid.
8190
- `drop_frames`: frames with function_name fully matching regexp string will be dropped from the samples,
8291
along with their successors.
8392
- `keep_frames`: frames with function_name fully matching regexp string will be kept, even if it matches drop_functions.
@@ -96,6 +105,7 @@ function pprof(data::Union{Nothing, Vector{UInt}} = nothing,
96105
drop_frames::Union{Nothing, AbstractString} = nothing,
97106
keep_frames::Union{Nothing, AbstractString} = nothing,
98107
ui_relative_percentages::Bool = true,
108+
tagroot::Union{Nothing, AbstractString} = "taskid,threadid",
99109
)
100110
has_meta = false
101111
if data === nothing
@@ -319,8 +329,7 @@ function pprof(data::Union{Nothing, Vector{UInt}} = nothing,
319329
end
320330

321331
if web
322-
refresh(webhost = webhost, webport = webport, file = out,
323-
ui_relative_percentages = ui_relative_percentages)
332+
refresh(; webhost, webport, file = out, ui_relative_percentages, tagroot)
324333
end
325334

326335
out
@@ -361,6 +370,7 @@ function refresh(; webhost::AbstractString = "localhost",
361370
webport::Integer = 57599,
362371
file::AbstractString = "profile.pb.gz",
363372
ui_relative_percentages::Bool = true,
373+
tagroot::Union{AbstractString,Nothing} = "taskid,threadid",
364374
)
365375

366376
if proc[] === nothing
@@ -374,7 +384,11 @@ function refresh(; webhost::AbstractString = "localhost",
374384
relative_percentages_flag = ui_relative_percentages ? "-relative_percentages" : ""
375385

376386
proc[] = pprof_jll.pprof() do pprof_path
377-
open(pipeline(`$pprof_path -http=$webhost:$webport $relative_percentages_flag $file`))
387+
if tagroot !== nothing && !isempty(tagroot)
388+
open(pipeline(`$pprof_path -tagroot $tagroot -http=$webhost:$webport $relative_percentages_flag $file`))
389+
else
390+
open(pipeline(`$pprof_path -http=$webhost:$webport $relative_percentages_flag $file`))
391+
end
378392
end
379393
end
380394

0 commit comments

Comments
 (0)