Skip to content

Commit

Permalink
Show the metadata tags in the flamegraph UI by default
Browse files Browse the repository at this point in the history
  • Loading branch information
NHDaly committed Oct 20, 2023
1 parent 64148cb commit aeae439
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions src/PProf.jl
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ using Base.StackTraces: StackFrame
web = true, webhost = "localhost", webport = 57599,
out = "profile.pb.gz", from_c = true, full_signatures = true, drop_frames = "",
keep_frames = "", ui_relative_percentages = true, sampling_delay = nothing,
tagroot = "taskid,threadid"
)
pprof(FlameGraphs.flamegraph(); kwargs...)
Expand Down Expand Up @@ -78,6 +79,14 @@ You can also use `PProf.refresh(file="...")` to open a new file in the server.
- `from_c::Bool`: If `false`, exclude frames that come from from_c. Defaults to `true`.
- `full_signatures::Bool`: If `true`, methods are printed as signatures with full argument
types. If `false`, as only names. E.g. `eval(::Module, ::Any)` vs `eval`.
- `tagroot`: Set which metadata tags you want to turn into root frames for the profile. This
is used to view the metadata tags in the Flamegraph view. This should be a
comma-separated string, chosing from the following metadata options:
- `taskid`
- `threadid`
- `thread_sleeping`
- `cycle_clock`
Defaults to `"taskid,threadid"`, grouping by taskid then threadid.
- `drop_frames`: frames with function_name fully matching regexp string will be dropped from the samples,
along with their successors.
- `keep_frames`: frames with function_name fully matching regexp string will be kept, even if it matches drop_functions.
Expand All @@ -96,6 +105,7 @@ function pprof(data::Union{Nothing, Vector{UInt}} = nothing,
drop_frames::Union{Nothing, AbstractString} = nothing,
keep_frames::Union{Nothing, AbstractString} = nothing,
ui_relative_percentages::Bool = true,
tagroot::Union{Nothing, AbstractString} = "taskid,threadid",
)
has_meta = false
if data === nothing
Expand Down Expand Up @@ -319,8 +329,7 @@ function pprof(data::Union{Nothing, Vector{UInt}} = nothing,
end

if web
refresh(webhost = webhost, webport = webport, file = out,
ui_relative_percentages = ui_relative_percentages)
refresh(; webhost, webport, file = out, ui_relative_percentages, tagroot)
end

out
Expand Down Expand Up @@ -361,6 +370,7 @@ function refresh(; webhost::AbstractString = "localhost",
webport::Integer = 57599,
file::AbstractString = "profile.pb.gz",
ui_relative_percentages::Bool = true,
tagroot::Union{AbstractString,Nothing} = "taskid,threadid",
)

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

proc[] = pprof_jll.pprof() do pprof_path
open(pipeline(`$pprof_path -http=$webhost:$webport $relative_percentages_flag $file`))
if tagroot !== nothing && !isempty(tagroot)
open(pipeline(`$pprof_path -tagroot $tagroot -http=$webhost:$webport $relative_percentages_flag $file`))
else
open(pipeline(`$pprof_path -http=$webhost:$webport $relative_percentages_flag $file`))
end
end
end

Expand Down

0 comments on commit aeae439

Please sign in to comment.