@@ -196,10 +196,10 @@ 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 , wall_time_sched = 0 ,
199
+ function time_print (io:: IO , elapsedtime, bytes= 0 , gctime= 0 , allocs= 0 , lock_conflicts= 0 , compile_time= 0 , recompile_time= 0 , sched_time_avg = 0 ,
200
200
newline= false ; msg:: Union{String,Nothing} = nothing )
201
201
timestr = Ryu. writefixed (Float64 (elapsedtime/ 1e9 ), 6 )
202
- wall_time_sched_perc = wall_time_sched / (elapsedtime / 1e9 )
202
+ wall_time_sched_perc = sched_time_avg / (elapsedtime / 1e9 )
203
203
sched_thresh = 0.1
204
204
str = sprint () do io
205
205
if msg isa String
@@ -354,7 +354,7 @@ macro time(msg, ex)
354
354
local ret = @timed $ (esc (ex))
355
355
local _msg = $ (esc (msg))
356
356
local _msg_str = _msg === nothing ? _msg : string (_msg)
357
- 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)
357
+ 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. sched_time_avg , true ; msg= _msg_str)
358
358
ret. value
359
359
end
360
360
end
@@ -608,7 +608,7 @@ julia> stats.recompile_time
608
608
macro timed (ex)
609
609
quote
610
610
Experimental. @force_compile
611
- ScopedValues. @with Workqueue_sched_times => zeros (UInt, Threads. maxthreadid ()) begin
611
+ ScopedValues. @with task_times_per_thread => zeros (UInt, Threads . maxthreadid ()) sleep_times_per_thread => zeros (UInt, Threads. maxthreadid ()) begin
612
612
Experimental. @force_compile
613
613
Threads. lock_profiling (true )
614
614
local lock_conflicts = Threads. LOCK_CONFLICT_COUNT[]
@@ -624,9 +624,15 @@ macro timed(ex)
624
624
Threads. lock_profiling (false ))
625
625
)
626
626
local diff = GC_Diff (gc_num (), stats)
627
- # filter out zeros which can only happen if nothing was scheduled
628
- local sched_times = Int .(filter (> (0 ), Workqueue_sched_times[]))
629
- local wall_time_sched = isempty (sched_times) ? 0 : sum (Int (elapsedtime) .- sched_times) / length (sched_times)
627
+ local sched_times = Int[]
628
+ for i in 1 : Threads. maxthreadid ()
629
+ # filter out zeros in task timers which can only happen if nothing was scheduled
630
+ if task_times_per_thread[][i] != 0
631
+ # subtract task and sleep times from global elapsed time to get scheduling time per thread
632
+ push! (sched_times, Int (elapsedtime) - Int (task_times_per_thread[][i]) - Int (sleep_times_per_thread[][i]))
633
+ end
634
+ end
635
+ local sched_time_avg = isempty (sched_times) ? 0 : sum (sched_times) / length (sched_times)
630
636
631
637
(
632
638
value= val,
@@ -637,7 +643,7 @@ macro timed(ex)
637
643
lock_conflicts= lock_conflicts,
638
644
compile_time= compile_elapsedtimes[1 ]/ 1e9 ,
639
645
recompile_time= compile_elapsedtimes[2 ]/ 1e9 ,
640
- wall_time_sched = wall_time_sched / 1e9
646
+ sched_time_avg = sched_time_avg / 1e9
641
647
)
642
648
end
643
649
end
0 commit comments