Skip to content

Commit

Permalink
Profile: allocate buffer for n instruction pointers per thread (#41821)
Browse files Browse the repository at this point in the history
  • Loading branch information
IanButterworth committed Aug 11, 2021
1 parent cc3fc0b commit c12e63f
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions stdlib/Profile/src/Profile.jl
Original file line number Diff line number Diff line change
Expand Up @@ -40,26 +40,32 @@ end
init(; n::Integer, delay::Real))
Configure the `delay` between backtraces (measured in seconds), and the number `n` of
instruction pointers that may be stored. Each instruction pointer corresponds to a single
instruction pointers that may be stored per thread. Each instruction pointer corresponds to a single
line of code; backtraces generally consist of a long list of instruction pointers. Current
settings can be obtained by calling this function with no arguments, and each can be set
independently using keywords or in the order `(n, delay)`.
!!! compat "Julia 1.8"
As of Julia 1.8, this function allocates space for `n` instruction pointers per thread being profiled.
Previously this was `n` total.
"""
function init(; n::Union{Nothing,Integer} = nothing, delay::Union{Nothing,Real} = nothing)
n_cur = ccall(:jl_profile_maxlen_data, Csize_t, ())
delay_cur = ccall(:jl_profile_delay_nsec, UInt64, ())/10^9
if n === nothing && delay === nothing
return Int(n_cur), delay_cur
end
nnew = (n === nothing) ? n_cur : n
nthreads = Sys.iswindows() ? 1 : Threads.nthreads() # windows only profiles the main thread
nnew = (n === nothing) ? n_cur : n * nthreads
delaynew = (delay === nothing) ? delay_cur : delay
init(nnew, delaynew)
end

function init(n::Integer, delay::Real)
status = ccall(:jl_profile_init, Cint, (Csize_t, UInt64), n, round(UInt64,10^9*delay))
nthreads = Sys.iswindows() ? 1 : Threads.nthreads() # windows only profiles the main thread
status = ccall(:jl_profile_init, Cint, (Csize_t, UInt64), n * nthreads, round(UInt64,10^9*delay))
if status == -1
error("could not allocate space for ", n, " instruction pointers")
error("could not allocate space for ", n, " instruction pointers per thread being profiled ($nthreads threads)")
end
end

Expand Down

2 comments on commit c12e63f

@nanosoldier
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Executing the daily package evaluation, I will reply here when finished:

@nanosoldier runtests(ALL, isdaily = true)

@nanosoldier
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your package evaluation job has completed - possible new issues were detected. A full report can be found here.

Please sign in to comment.