diff options
author | Douglas Wilson <douglas.wilson@gmail.com> | 2021-01-01 12:45:06 +0000 |
---|---|---|
committer | Ben Gamari <ben@smart-cactus.org> | 2021-05-04 19:12:10 -0400 |
commit | f4ac60b95c8eed9d6c3c905338156bfe42351db5 (patch) | |
tree | 632f1bebf3dbaed7c40248d14eb303e84c9ec600 /rts/Stats.c | |
parent | fa0888718ddf74586da6e42bda662340e6f0e1c5 (diff) | |
download | haskell-f4ac60b95c8eed9d6c3c905338156bfe42351db5.tar.gz |
rts: stats: Some fixes to stats for sequential gcs
Solves #19147. When n_capabilities > 1 we were not correctly accounting
for gc time for sequential collections. In this case par_n_gcthreads ==
1, however it is not guaranteed that the single gc thread is capability 0.
A similar issue for copied is addressed as well.
(cherry picked from commit f49d6fb27336297d6d7a46269a22dd98c131b4a8)
Diffstat (limited to 'rts/Stats.c')
-rw-r--r-- | rts/Stats.c | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/rts/Stats.c b/rts/Stats.c index 282e799d23..895ff3f040 100644 --- a/rts/Stats.c +++ b/rts/Stats.c @@ -523,10 +523,18 @@ stat_endGC (Capability *cap, gc_thread *initiating_gct, W_ live, W_ copied, W_ s initiating_gct->gc_start_elapsed - initiating_gct->gc_sync_start_elapsed; stats.gc.elapsed_ns = current_elapsed - initiating_gct->gc_start_elapsed; stats.gc.cpu_ns = 0; - for (unsigned int i=0; i < par_n_threads; i++) { - gc_thread *gct = gc_threads[i]; - ASSERT(gct->gc_end_cpu >= gct->gc_start_cpu); - stats.gc.cpu_ns += gct->gc_end_cpu - gct->gc_start_cpu; + // see Note [n_gc_threads] + // par_n_threads is set to n_gc_threads at the single callsite of this + // function + if (par_n_threads == 1) { + ASSERT(initiating_gct->gc_end_cpu >= initiating_gct->gc_start_cpu); + stats.gc.cpu_ns += initiating_gct->gc_end_cpu - initiating_gct->gc_start_cpu; + } else { + for (unsigned int i=0; i < par_n_threads; i++) { + gc_thread *gct = gc_threads[i]; + ASSERT(gct->gc_end_cpu >= gct->gc_start_cpu); + stats.gc.cpu_ns += gct->gc_end_cpu - gct->gc_start_cpu; + } } } // ------------------------------------------------- |