Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC
Commits:
-
02e68a86
by Brandon Simmons at 2026-03-13T15:13:19-04:00
7 changed files:
- libraries/base/src/GHC/Stats.hs
- libraries/ghc-internal/CHANGELOG.md
- libraries/ghc-internal/src/GHC/Internal/Stats.hsc
- rts/Stats.c
- rts/include/RtsAPI.h
- testsuite/tests/interface-stability/ghc-experimental-exports.stdout
- testsuite/tests/interface-stability/ghc-experimental-exports.stdout-mingw32
Changes:
| ... | ... | @@ -26,6 +26,7 @@ |
| 26 | 26 | -- proposal
|
| 27 | 27 | -- #289](https://github.com/haskell/core-libraries-committee/issues/289). These
|
| 28 | 28 | -- declarations are now instead available from the @ghc-experimental@ package.
|
| 29 | +-- @ghc-experimental@ contains additional metrics not added to the API here.
|
|
| 29 | 30 | |
| 30 | 31 | module GHC.Stats
|
| 31 | 32 | ( -- * Runtime statistics
|
| ... | ... | @@ -3,6 +3,7 @@ |
| 3 | 3 | ## 9.1401.0 -- yyyy-mm-dd
|
| 4 | 4 | |
| 5 | 5 | * Introduce `dataToCodeQ` and `liftDataTyped`, typed variants of `dataToExpQ` and `liftData` respectively.
|
| 6 | +* Add new `gc_sync_elapsed_ns` counter to GHC.Internal.Stats
|
|
| 6 | 7 | |
| 7 | 8 | ## 9.1001.0 -- 2024-05-01
|
| 8 | 9 |
| ... | ... | @@ -111,6 +111,8 @@ data RTSStats = RTSStats { |
| 111 | 111 | , gc_cpu_ns :: RtsTime
|
| 112 | 112 | -- | Total elapsed time used by the GC
|
| 113 | 113 | , gc_elapsed_ns :: RtsTime
|
| 114 | + -- | Total elapsed time used during GC synchronization
|
|
| 115 | + , gc_sync_elapsed_ns :: RtsTime
|
|
| 114 | 116 | -- | Total CPU time (at the previous GC)
|
| 115 | 117 | , cpu_ns :: RtsTime
|
| 116 | 118 | -- | Total elapsed time (at the previous GC)
|
| ... | ... | @@ -234,6 +236,7 @@ getRTSStats = do |
| 234 | 236 | mutator_elapsed_ns <- (# peek RTSStats, mutator_elapsed_ns) p
|
| 235 | 237 | gc_cpu_ns <- (# peek RTSStats, gc_cpu_ns) p
|
| 236 | 238 | gc_elapsed_ns <- (# peek RTSStats, gc_elapsed_ns) p
|
| 239 | + gc_sync_elapsed_ns <- (# peek RTSStats, gc_sync_elapsed_ns) p
|
|
| 237 | 240 | cpu_ns <- (# peek RTSStats, cpu_ns) p
|
| 238 | 241 | elapsed_ns <- (# peek RTSStats, elapsed_ns) p
|
| 239 | 242 | nonmoving_gc_sync_cpu_ns <- (# peek RTSStats, nonmoving_gc_sync_cpu_ns) p
|
| ... | ... | @@ -163,6 +163,7 @@ initStats0(void) |
| 163 | 163 | .mutator_elapsed_ns = 0,
|
| 164 | 164 | .gc_cpu_ns = 0,
|
| 165 | 165 | .gc_elapsed_ns = 0,
|
| 166 | + .gc_sync_elapsed_ns = 0,
|
|
| 166 | 167 | .cpu_ns = 0,
|
| 167 | 168 | .elapsed_ns = 0,
|
| 168 | 169 | .nonmoving_gc_cpu_ns = 0,
|
| ... | ... | @@ -288,6 +289,8 @@ stat_endExit(void) |
| 288 | 289 | RELEASE_LOCK(&stats_mutex);
|
| 289 | 290 | }
|
| 290 | 291 | |
| 292 | +// This is only called in the threaded RTS. On non-threaded RTS `gc_sync_start_elapsed`
|
|
| 293 | +// is conditonally set in `stat_startGC`.
|
|
| 291 | 294 | void
|
| 292 | 295 | stat_startGCSync (gc_thread *gct)
|
| 293 | 296 | {
|
| ... | ... | @@ -433,6 +436,11 @@ stat_startGC (Capability *cap, gc_thread *gct) |
| 433 | 436 | }
|
| 434 | 437 | |
| 435 | 438 | gct->gc_start_elapsed = getProcessElapsedTime();
|
| 439 | +#if !defined(THREADED_RTS)
|
|
| 440 | + // Non-threaded RTS has no sync phase. Initializing in this way makes the
|
|
| 441 | + // calculated statistics correctly read zero.
|
|
| 442 | + gct->gc_sync_start_elapsed = gct->gc_start_elapsed;
|
|
| 443 | +#endif
|
|
| 436 | 444 | |
| 437 | 445 | // Post EVENT_GC_START with the same timestamp as used for stats
|
| 438 | 446 | // (though converted from Time=StgInt64 to EventTimestamp=StgWord64).
|
| ... | ... | @@ -548,6 +556,7 @@ stat_endGC (Capability *cap, gc_thread *initiating_gct, W_ live, W_ copied, W_ s |
| 548 | 556 | }
|
| 549 | 557 | stats.gc_cpu_ns += stats.gc.cpu_ns;
|
| 550 | 558 | stats.gc_elapsed_ns += stats.gc.elapsed_ns;
|
| 559 | + stats.gc_sync_elapsed_ns += stats.gc.sync_elapsed_ns;
|
|
| 551 | 560 | |
| 552 | 561 | if (gen == RtsFlags.GcFlags.generations-1) { // major GC?
|
| 553 | 562 | stats.major_gcs++;
|
| ... | ... | @@ -915,6 +924,8 @@ static void report_summary(const RTSSummaryStats* sum) |
| 915 | 924 | statsPrintf(" GC time %7.3fs (%7.3fs elapsed)\n",
|
| 916 | 925 | TimeToSecondsDbl(stats.gc_cpu_ns),
|
| 917 | 926 | TimeToSecondsDbl(stats.gc_elapsed_ns));
|
| 927 | + statsPrintf(" GC SYNC time (%7.3fs elapsed)\n",
|
|
| 928 | + TimeToSecondsDbl(stats.gc_sync_elapsed_ns));
|
|
| 918 | 929 | if (RtsFlags.GcFlags.useNonmoving) {
|
| 919 | 930 | statsPrintf(
|
| 920 | 931 | " CONC GC time %7.3fs (%7.3fs elapsed)\n",
|
| ... | ... | @@ -1069,6 +1080,7 @@ static void report_machine_readable (const RTSSummaryStats * sum) |
| 1069 | 1080 | TimeToSecondsDbl(stats.mutator_elapsed_ns));
|
| 1070 | 1081 | MR_STAT("GC_cpu_seconds", "f", TimeToSecondsDbl(stats.gc_cpu_ns));
|
| 1071 | 1082 | MR_STAT("GC_wall_seconds", "f", TimeToSecondsDbl(stats.gc_elapsed_ns));
|
| 1083 | + MR_STAT("GC_sync_wall_seconds", "f", TimeToSecondsDbl(stats.gc_sync_elapsed_ns));
|
|
| 1072 | 1084 | |
| 1073 | 1085 | // end backward compatibility
|
| 1074 | 1086 |
| ... | ... | @@ -240,6 +240,8 @@ typedef struct _RTSStats { |
| 240 | 240 | Time gc_cpu_ns;
|
| 241 | 241 | // Total elapsed time used by the GC
|
| 242 | 242 | Time gc_elapsed_ns;
|
| 243 | + // Total elapsed time used during GC synchronization
|
|
| 244 | + Time gc_sync_elapsed_ns;
|
|
| 243 | 245 | // Total CPU time (at the previous GC)
|
| 244 | 246 | Time cpu_ns;
|
| 245 | 247 | // Total elapsed time (at the previous GC)
|
| ... | ... | @@ -6587,6 +6587,7 @@ module GHC.Stats.Experimental where |
| 6587 | 6587 | mutator_elapsed_ns :: RtsTime,
|
| 6588 | 6588 | gc_cpu_ns :: RtsTime,
|
| 6589 | 6589 | gc_elapsed_ns :: RtsTime,
|
| 6590 | + gc_sync_elapsed_ns :: RtsTime,
|
|
| 6590 | 6591 | cpu_ns :: RtsTime,
|
| 6591 | 6592 | elapsed_ns :: RtsTime,
|
| 6592 | 6593 | nonmoving_gc_sync_cpu_ns :: RtsTime,
|
| ... | ... | @@ -6590,6 +6590,7 @@ module GHC.Stats.Experimental where |
| 6590 | 6590 | mutator_elapsed_ns :: RtsTime,
|
| 6591 | 6591 | gc_cpu_ns :: RtsTime,
|
| 6592 | 6592 | gc_elapsed_ns :: RtsTime,
|
| 6593 | + gc_sync_elapsed_ns :: RtsTime,
|
|
| 6593 | 6594 | cpu_ns :: RtsTime,
|
| 6594 | 6595 | elapsed_ns :: RtsTime,
|
| 6595 | 6596 | nonmoving_gc_sync_cpu_ns :: RtsTime,
|