Skip to content

Commit 60280a7

Browse files
committed
Address review comments
1 parent 82e40cf commit 60280a7

2 files changed

Lines changed: 8 additions & 3 deletions

File tree

base/timing.jl

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,11 @@ function gc_alloc_count(diff::GC_Diff)
6868
diff.malloc + diff.realloc + diff.poolalloc + diff.bigalloc
6969
end
7070

71-
lock_waiting_time(tid::Int16) = ccall(:jl_get_thread_lock_waiting_time, UInt64, (Int16,), tid)
72-
lock_waiting_time() = ccall(:jl_get_lock_waiting_time, UInt64, ())
71+
# Retrieve the specified thread's, or the aggregated value across all threads
72+
# of wait time on all the locks for which wait-time measurement has been
73+
# enabled (for RAI, currently only the codegen lock).
74+
lock_waiting_time_ns(tid::Int16) = ccall(:jl_get_thread_lock_waiting_time, UInt64, (Int16,), tid)
75+
lock_waiting_time_ns() = ccall(:jl_get_lock_waiting_time, UInt64, ())
7376

7477
# cumulative total time spent on compilation and recompilation, in nanoseconds
7578
function cumulative_compile_time_ns()

src/threading.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -949,8 +949,10 @@ JL_DLLEXPORT uint64_t jl_get_lock_waiting_time(void)
949949
{
950950
uint64_t waiting_time = 0;
951951
int nthreads = jl_atomic_load_acquire(&jl_n_threads);
952+
int ngcthreads = jl_atomic_load_acquire(&jl_n_gc_threads);
953+
int nmutatorthreads = nthreads - ngcthreads;
952954
jl_ptls_t *all_tls_states = jl_atomic_load_relaxed(&jl_all_tls_states);
953-
for (int i = 0; i < nthreads; i++) {
955+
for (int i = 0; i < nmutatorthreads; i++) {
954956
jl_ptls_t ptls = all_tls_states[i];
955957
if (ptls) {
956958
waiting_time += jl_atomic_load_relaxed(&ptls->lock_waiting_time);

0 commit comments

Comments
 (0)