Skip to content

Commit 3b79815

Browse files
committed
Add wake_all_threads_time metric
Accumulates the time spent in the all-threads wakeup loop in `jl_wakeup_thread`.
1 parent 061a139 commit 3b79815

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/partr.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,13 @@ static void wake_libuv(void) JL_NOTSAFEPOINT
279279
JULIA_DEBUG_SLEEPWAKE( io_wakeup_leave = cycleclock() );
280280
}
281281

282+
_Atomic(uint64_t) wake_all_threads_time = 0;
283+
284+
JL_DLLEXPORT uint64_t jl_get_wake_all_threads_time(void)
285+
{
286+
return jl_atomic_load_relaxed(&wake_all_threads_time);
287+
}
288+
282289
/* ensure thread tid is awake if necessary */
283290
JL_DLLEXPORT void jl_wakeup_thread(int16_t tid) JL_NOTSAFEPOINT
284291
{
@@ -317,12 +324,15 @@ JL_DLLEXPORT void jl_wakeup_thread(int16_t tid) JL_NOTSAFEPOINT
317324
// something added to the multi-queue: notify all threads
318325
// in the future, we might want to instead wake some fraction of threads,
319326
// and let each of those wake additional threads if they find work
327+
uint64_t tw = jl_hrtime();
320328
int anysleep = 0;
321329
int nthreads = jl_atomic_load_acquire(&jl_n_threads);
322330
for (tid = 0; tid < nthreads; tid++) {
323331
if (tid != self)
324332
anysleep |= wake_thread(tid);
325333
}
334+
tw = jl_hrtime() - tw;
335+
jl_atomic_fetch_add_relaxed(&wake_all_threads_time, tw);
326336
// check if we need to notify uv_run too
327337
if (uvlock != ct && anysleep) {
328338
jl_fence();

0 commit comments

Comments
 (0)