diff --git a/base/Base.jl b/base/Base.jl index f4e2e7d9dcb4d9..16d70c0cface2d 100644 --- a/base/Base.jl +++ b/base/Base.jl @@ -461,7 +461,7 @@ end const PROF_PEEK_COND = Ref{Base.AsyncCondition}() function prof_peek() wait(PROF_PEEK_COND[]) - Base.require(Base.PkgId(Base.UUID("9abbd945-dff8-562f-b5e8-e1ebf5ef1b79"), "Profile")).profile_peek_report() + Base.require(Base.PkgId(Base.UUID("9abbd945-dff8-562f-b5e8-e1ebf5ef1b79"), "Profile")).profile_peek_report[]() Threads.@spawn prof_peek() end diff --git a/stdlib/Profile/src/Profile.jl b/stdlib/Profile/src/Profile.jl index e239cadb601fbd..d422cea82b6692 100644 --- a/stdlib/Profile/src/Profile.jl +++ b/stdlib/Profile/src/Profile.jl @@ -12,7 +12,7 @@ const nmeta = 4 # number of metadata fields per block (threadid, taskid, cpu_cyc precompile_script = """ import Profile Profile.@profile sleep(1) -Profile.profile_peek_report() +Profile.profile_peek_report[]() """ # deprecated functions: use `getdict` instead @@ -41,10 +41,10 @@ macro profile(ex) end -# An internal function called to show the report after a `ctrl-z` profile "peek". -function profile_peek_report() - print(groupby = :thread) -end + +# An internal function called to show the report after an information request (SIGINFO or SIGUSR1). +# This is a ref so that it can be overridden. +const profile_peek_report = Ref{Function}(() -> print(groupby = [:thread, :task])) get_peek_duration() = ccall(:jl_get_profile_peek_duration, Float64, ()) set_peek_duration(t::Float64) = ccall(:jl_set_profile_peek_duration, Cvoid, (Float64,), t)