Skip to content

Commit 46453cd

Browse files
don't show limit warning during __init__ (#42214)
1 parent e65296f commit 46453cd

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

stdlib/Profile/src/Profile.jl

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ end
3939
####
4040

4141
"""
42-
init(; n::Integer, delay::Real))
42+
init(; n::Integer, delay::Real)
4343
4444
Configure the `delay` between backtraces (measured in seconds), and the number `n` of instruction pointers that may be
4545
stored per thread. Each instruction pointer corresponds to a single line of code; backtraces generally consist of a long
@@ -51,18 +51,18 @@ using keywords or in the order `(n, delay)`.
5151
As of Julia 1.8, this function allocates space for `n` instruction pointers per thread being profiled.
5252
Previously this was `n` total.
5353
"""
54-
function init(; n::Union{Nothing,Integer} = nothing, delay::Union{Nothing,Real} = nothing)
54+
function init(; n::Union{Nothing,Integer} = nothing, delay::Union{Nothing,Real} = nothing, limitwarn::Bool = true)
5555
n_cur = ccall(:jl_profile_maxlen_data, Csize_t, ())
5656
delay_cur = ccall(:jl_profile_delay_nsec, UInt64, ())/10^9
5757
if n === nothing && delay === nothing
5858
return Int(n_cur), delay_cur
5959
end
6060
nnew = (n === nothing) ? n_cur : n
6161
delaynew = (delay === nothing) ? delay_cur : delay
62-
init(nnew, delaynew)
62+
init(nnew, delaynew; limitwarn)
6363
end
6464

65-
function init(n::Integer, delay::Real)
65+
function init(n::Integer, delay::Real; limitwarn::Bool = true)
6666
nthreads = Sys.iswindows() ? 1 : Threads.nthreads() # windows only profiles the main thread
6767
sample_size_bytes = sizeof(Ptr) # == Sys.WORD_SIZE / 8
6868
buffer_samples = n * nthreads
@@ -72,7 +72,7 @@ function init(n::Integer, delay::Real)
7272
buffer_samples_per_thread = floor(Int, buffer_size_bytes_per_thread / sample_size_bytes)
7373
buffer_samples = buffer_samples_per_thread * nthreads
7474
buffer_size_bytes = buffer_samples * sample_size_bytes
75-
@warn "Requested profile buffer limited to 512MB (n = $buffer_samples_per_thread per thread) given that this system is 32-bit"
75+
limitwarn && @warn "Requested profile buffer limited to 512MB (n = $buffer_samples_per_thread per thread) given that this system is 32-bit"
7676
end
7777
status = ccall(:jl_profile_init, Cint, (Csize_t, UInt64), buffer_samples, round(UInt64,10^9*delay))
7878
if status == -1
@@ -86,9 +86,9 @@ end
8686
if Sys.iswindows() && Sys.WORD_SIZE == 32
8787
# The Win32 unwinder is 1000x slower than elsewhere (around 1ms/frame),
8888
# so we don't want to slow the program down by quite that much
89-
__init__() = init(1_000_000, 0.01)
89+
__init__() = init(1_000_000, 0.01, limitwarn = false)
9090
else
91-
__init__() = init(10_000_000, 0.001)
91+
__init__() = init(10_000_000, 0.001, limitwarn = false)
9292
end
9393

9494
"""

0 commit comments

Comments
 (0)