@@ -196,8 +196,8 @@ function format_bytes(bytes; binary=true) # also used by InteractiveUtils
196
196
end
197
197
end
198
198
199
- function time_print (io:: IO , elapsedtime, bytes= 0 , gctime= 0 , allocs= 0 , lock_conflicts= 0 , compile_time= 0 , recompile_time= 0 , newline = false ;
200
- msg:: Union{String,Nothing} = nothing )
199
+ function time_print (io:: IO , elapsedtime, bytes= 0 , gctime= 0 , allocs= 0 , lock_conflicts= 0 , compile_time= 0 , recompile_time= 0 , wall_time_sched = 0 ,
200
+ newline = false ; msg:: Union{String,Nothing} = nothing )
201
201
timestr = Ryu. writefixed (Float64 (elapsedtime/ 1e9 ), 6 )
202
202
str = sprint () do io
203
203
if msg isa String
@@ -223,12 +223,22 @@ function time_print(io::IO, elapsedtime, bytes=0, gctime=0, allocs=0, lock_confl
223
223
end
224
224
print (io, Ryu. writefixed (Float64 (100 * gctime/ elapsedtime), 2 ), " % gc time" )
225
225
end
226
+ wall_time_sched_perc = wall_time_sched / (elapsedtime / 1e9 )
227
+ if wall_time_sched_perc > 0.1
228
+ if bytes != 0 || allocs != 0 || gctime > 0
229
+ print (io, " , " )
230
+ end
231
+ print (io, Ryu. writefixed (Float64 (100 * wall_time_sched_perc), 2 ), " % wall time scheduling" )
232
+ end
226
233
if lock_conflicts > 0
234
+ if bytes != 0 || allocs != 0 || gctime > 0 || wall_time_sched_perc > 0.1
235
+ print (io, " , " )
236
+ end
227
237
plural = lock_conflicts == 1 ? " " : " s"
228
238
print (io, " , " , lock_conflicts, " lock conflict$plural " )
229
239
end
230
240
if compile_time > 0
231
- if bytes != 0 || allocs != 0 || gctime > 0
241
+ if bytes != 0 || allocs != 0 || gctime > 0 || wall_time_sched_perc > 0.1 || lock_conflicts > 0
232
242
print (io, " , " )
233
243
end
234
244
print (io, Ryu. writefixed (Float64 (100 * compile_time/ elapsedtime), 2 ), " % compilation time" )
@@ -343,7 +353,7 @@ macro time(msg, ex)
343
353
local ret = @timed $ (esc (ex))
344
354
local _msg = $ (esc (msg))
345
355
local _msg_str = _msg === nothing ? _msg : string (_msg)
346
- time_print (stdout , ret. time* 1e9 , ret. gcstats. allocd, ret. gcstats. total_time, gc_alloc_count (ret. gcstats), ret. lock_conflicts, ret. compile_time* 1e9 , ret. recompile_time* 1e9 , true ; msg= _msg_str)
356
+ time_print (stdout , ret. time* 1e9 , ret. gcstats. allocd, ret. gcstats. total_time, gc_alloc_count (ret. gcstats), ret. lock_conflicts, ret. compile_time* 1e9 , ret. recompile_time* 1e9 , ret . wall_time_sched, true ; msg= _msg_str)
347
357
ret. value
348
358
end
349
359
end
@@ -603,13 +613,19 @@ macro timed(ex)
603
613
local elapsedtime = time_ns ()
604
614
cumulative_compile_timing (true )
605
615
local compile_elapsedtimes = cumulative_compile_time_ns ()
606
- local val = @__tryfinally ($ (esc (ex)),
607
- (elapsedtime = time_ns () - elapsedtime;
608
- cumulative_compile_timing (false );
609
- compile_elapsedtimes = cumulative_compile_time_ns () .- compile_elapsedtimes;
610
- lock_conflicts = Threads. LOCK_CONFLICT_COUNT[] - lock_conflicts;
611
- Threads. lock_profiling (false ))
612
- )
616
+ local wall_time_sched = 0.0
617
+ ScopedValues. @with Workqueue_sched_times => zeros (UInt, Threads. maxthreadid ()) begin
618
+ sched_ts = copy (Base. Workqueue_sched_times[])
619
+ local val = @__tryfinally ($ (esc (ex)),
620
+ (elapsedtime = time_ns () - elapsedtime;
621
+ cumulative_compile_timing (false );
622
+ compile_elapsedtimes = cumulative_compile_time_ns () .- compile_elapsedtimes;
623
+ lock_conflicts = Threads. LOCK_CONFLICT_COUNT[] - lock_conflicts;
624
+ Threads. lock_profiling (false ))
625
+ )
626
+ wall_time_sched = sum (Base. Workqueue_sched_times[] .- sched_ts) / (Threads. nthreads (:interactive ) + Threads. nthreads (:default ))
627
+ end
628
+
613
629
local diff = GC_Diff (gc_num (), stats)
614
630
(
615
631
value= val,
@@ -619,7 +635,8 @@ macro timed(ex)
619
635
gcstats= diff,
620
636
lock_conflicts= lock_conflicts,
621
637
compile_time= compile_elapsedtimes[1 ]/ 1e9 ,
622
- recompile_time= compile_elapsedtimes[2 ]/ 1e9
638
+ recompile_time= compile_elapsedtimes[2 ]/ 1e9 ,
639
+ wall_time_sched= wall_time_sched/ 1e9
623
640
)
624
641
end
625
642
end
0 commit comments