Skip to content

Commit

Permalink
Fix for v1.6
Browse files Browse the repository at this point in the history
  • Loading branch information
NHDaly committed Oct 20, 2023
1 parent b2ffe7c commit 91d30ef
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 5 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
18 changes: 16 additions & 2 deletions test/PProf.jl
Original file line number Diff line number Diff line change
Expand Up @@ -110,18 +110,32 @@ end
end
@testset for i in 1:4
if i == 1
if !Profile.has_meta
continue
end
data = Profile.fetch(include_meta = true)
args = (data,)
elseif i == 2
if !Profile.has_meta
continue
end
data,lidict = Profile.retrieve(include_meta = true)
args = (data, lidict)
elseif i == 3
# Ensure we are backwards compatible with older, non-meta profiles
data = Profile.fetch(include_meta = false)
if Profile.has_meta
data = Profile.fetch(include_meta = false)
else
data = Profile.fetch()
end
args = (data,)
else
# Ensure we are backwards compatible with older, non-meta profiles
data,lidict = Profile.retrieve(include_meta = false)
if Profile.has_meta
data,lidict = Profile.retrieve(include_meta = false)
else
data,lidict = Profile.retrieve()
end
args = (data, lidict)
end

Expand Down

0 comments on commit 91d30ef

Please sign in to comment.