[commit: ghc] master: rts: Fix gc timing (d9f0c24)
git at git.haskell.org
git at git.haskell.org
Wed Nov 15 20:05:58 UTC 2017
Repository : ssh://git@git.haskell.org/ghc
On branch : master
Link : http://ghc.haskell.org/trac/ghc/changeset/d9f0c24dd01b2f2a9a5ccc2fc45e93064d4ba0c1/ghc
>---------------------------------------------------------------
commit d9f0c24dd01b2f2a9a5ccc2fc45e93064d4ba0c1
Author: Douglas Wilson <douglas.wilson at gmail.com>
Date: Wed Nov 15 11:40:54 2017 -0500
rts: Fix gc timing
We were accumulating the gc times of the previous gc.
`stats.gc.{cpu,elappsed}_ns` were being accumulated into
`stats.gc_{cpu,elapsed}_ns` before they were set.
There is also a change in that heap profiling will no longer cause gc
events to
be emitted.
Reviewers: bgamari, erikd, simonmar
Reviewed By: bgamari
Subscribers: rwbarton, thomie
GHC Trac Issues: #14257, #14445
Differential Revision: https://phabricator.haskell.org/D4184
>---------------------------------------------------------------
d9f0c24dd01b2f2a9a5ccc2fc45e93064d4ba0c1
rts/Stats.c | 37 +++++++++++++++++++++----------------
1 file changed, 21 insertions(+), 16 deletions(-)
diff --git a/rts/Stats.c b/rts/Stats.c
index 6a5f801..8f7865b 100644
--- a/rts/Stats.c
+++ b/rts/Stats.c
@@ -310,6 +310,26 @@ stat_endGC (Capability *cap, gc_thread *gct,
stats.gc.par_max_copied_bytes = par_max_copied * sizeof(W_);
stats.gc.par_balanced_copied_bytes = par_balanced_copied * sizeof(W_);
+ bool stats_enabled =
+ RtsFlags.GcFlags.giveStats != NO_GC_STATS ||
+ rtsConfig.gcDoneHook != NULL;
+
+ if (stats_enabled
+ || RtsFlags.ProfFlags.doHeapProfile) // heap profiling needs GC_tot_time
+ {
+ // We only update the times when stats are explicitly enabled since
+ // getProcessTimes (e.g. requiring a system call) can be expensive on
+ // some platforms.
+ Time current_cpu, current_elapsed;
+ getProcessTimes(¤t_cpu, ¤t_elapsed);
+ stats.cpu_ns = current_cpu - start_init_cpu;
+ stats.elapsed_ns = current_elapsed - start_init_elapsed;
+
+ stats.gc.sync_elapsed_ns =
+ gct->gc_start_elapsed - gct->gc_sync_start_elapsed;
+ stats.gc.elapsed_ns = current_elapsed - gct->gc_start_elapsed;
+ stats.gc.cpu_ns = current_cpu - gct->gc_start_cpu;
+ }
// -------------------------------------------------
// Update the cumulative stats
@@ -354,23 +374,8 @@ stat_endGC (Capability *cap, gc_thread *gct,
// -------------------------------------------------
// Do the more expensive bits only when stats are enabled.
- if (RtsFlags.GcFlags.giveStats != NO_GC_STATS ||
- rtsConfig.gcDoneHook != NULL ||
- RtsFlags.ProfFlags.doHeapProfile) // heap profiling needs GC_tot_time
+ if (stats_enabled)
{
- // We only update the times when stats are explicitly enabled since
- // getProcessTimes (e.g. requiring a system call) can be expensive on
- // some platforms.
- Time current_cpu, current_elapsed;
- getProcessTimes(¤t_cpu, ¤t_elapsed);
- stats.cpu_ns = current_cpu - start_init_cpu;
- stats.elapsed_ns = current_elapsed - start_init_elapsed;
-
- stats.gc.sync_elapsed_ns =
- gct->gc_start_elapsed - gct->gc_sync_start_elapsed;
- stats.gc.elapsed_ns = current_elapsed - gct->gc_start_elapsed;
- stats.gc.cpu_ns = current_cpu - gct->gc_start_cpu;
-
// -------------------------------------------------
// Emit events to the event log
More information about the ghc-commits
mailing list