39
39
# ###
40
40
41
41
"""
42
- init(; n::Integer, delay::Real))
42
+ init(; n::Integer, delay::Real)
43
43
44
44
Configure the `delay` between backtraces (measured in seconds), and the number `n` of instruction pointers that may be
45
45
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)`.
51
51
As of Julia 1.8, this function allocates space for `n` instruction pointers per thread being profiled.
52
52
Previously this was `n` total.
53
53
"""
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 )
55
55
n_cur = ccall (:jl_profile_maxlen_data , Csize_t, ())
56
56
delay_cur = ccall (:jl_profile_delay_nsec , UInt64, ())/ 10 ^ 9
57
57
if n === nothing && delay === nothing
58
58
return Int (n_cur), delay_cur
59
59
end
60
60
nnew = (n === nothing ) ? n_cur : n
61
61
delaynew = (delay === nothing ) ? delay_cur : delay
62
- init (nnew, delaynew)
62
+ init (nnew, delaynew; limitwarn )
63
63
end
64
64
65
- function init (n:: Integer , delay:: Real )
65
+ function init (n:: Integer , delay:: Real ; limitwarn :: Bool = true )
66
66
nthreads = Sys. iswindows () ? 1 : Threads. nthreads () # windows only profiles the main thread
67
67
sample_size_bytes = sizeof (Ptr) # == Sys.WORD_SIZE / 8
68
68
buffer_samples = n * nthreads
@@ -72,7 +72,7 @@ function init(n::Integer, delay::Real)
72
72
buffer_samples_per_thread = floor (Int, buffer_size_bytes_per_thread / sample_size_bytes)
73
73
buffer_samples = buffer_samples_per_thread * nthreads
74
74
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"
76
76
end
77
77
status = ccall (:jl_profile_init , Cint, (Csize_t, UInt64), buffer_samples, round (UInt64,10 ^ 9 * delay))
78
78
if status == - 1
86
86
if Sys. iswindows () && Sys. WORD_SIZE == 32
87
87
# The Win32 unwinder is 1000x slower than elsewhere (around 1ms/frame),
88
88
# 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 )
90
90
else
91
- __init__ () = init (10_000_000 , 0.001 )
91
+ __init__ () = init (10_000_000 , 0.001 , limitwarn = false )
92
92
end
93
93
94
94
"""
0 commit comments