Skip to content

Error in accounting for GC cpu time in sequential collections

Summary

stat_endGC accounts for cpu time consumed by a garbage collection the following fragment:

        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;
        }

however, this is incorrect when accounting for a sequential collection when n_capabilities > 1. In this case, par_n_threads will be set to 1. However the cpu stats will not necessarily be on capability 0(i.e. in gc_threads[0]) which the fragment above assumes. The stats will be on the capability of the gc leader.

EDIT: I've also seen

      for (i=0; i < n_gc_threads; i++) {
          copied += RELAXED_LOAD(&gc_threads[i]->copied);
      }

in GC.c seems to have the same problem. Holding off fixing this for now, since I now suspect I may be confused

Steps to reproduce

I've not constructed a demonstration.

Expected behavior

n/a

Environment

  • GHC version used: head
Edited by Douglas Wilson
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information