summaryrefslogtreecommitdiff
path: root/rts
diff options
context:
space:
mode:
authorBen Gamari <ben@smart-cactus.org>2022-10-22 15:31:13 +0000
committerMarge Bot <ben+marge-bot@smart-cactus.org>2023-03-08 15:02:30 -0500
commit99d144d56598965daba30aa73e6c598b3245bb0f (patch)
tree85412a48b067b0308d0d4a249f66552a9e4827bd /rts
parent71b038a1261754c38cf984f7c578621c3217c3bf (diff)
downloadhaskell-99d144d56598965daba30aa73e6c598b3245bb0f.tar.gz
nonmoving: Don't show occupancy if we didn't collect live words
Diffstat (limited to 'rts')
-rw-r--r--rts/sm/NonMoving.c2
-rw-r--r--rts/sm/NonMovingCensus.c53
-rw-r--r--rts/sm/NonMovingCensus.h3
3 files changed, 41 insertions, 17 deletions
diff --git a/rts/sm/NonMoving.c b/rts/sm/NonMoving.c
index 697cdea6da..d7e4d943fb 100644
--- a/rts/sm/NonMoving.c
+++ b/rts/sm/NonMoving.c
@@ -1223,7 +1223,7 @@ static void nonmovingMark_(MarkQueue *mark_queue, StgWeak **dead_weaks, StgTSO *
traceConcSweepEnd();
#if defined(DEBUG)
if (RtsFlags.DebugFlags.nonmoving_gc)
- nonmovingPrintAllocatorCensus();
+ nonmovingPrintAllocatorCensus(true);
#endif
#if defined(TRACING)
if (RtsFlags.TraceFlags.nonmoving_gc)
diff --git a/rts/sm/NonMovingCensus.c b/rts/sm/NonMovingCensus.c
index 41b6f7433b..426179928b 100644
--- a/rts/sm/NonMovingCensus.c
+++ b/rts/sm/NonMovingCensus.c
@@ -23,7 +23,7 @@
static struct NonmovingAllocCensus
nonmovingAllocatorCensus_(struct NonmovingAllocator *alloc, bool collect_live_words)
{
- struct NonmovingAllocCensus census = {0, 0, 0, 0};
+ struct NonmovingAllocCensus census = {collect_live_words, 0, 0, 0, 0};
for (struct NonmovingSegment *seg = alloc->filled;
seg != NULL;
@@ -47,7 +47,7 @@ nonmovingAllocatorCensus_(struct NonmovingAllocator *alloc, bool collect_live_wo
census.n_active_segs++;
unsigned int n = nonmovingSegmentBlockCount(seg);
for (unsigned int i=0; i < n; i++) {
- if (nonmovingGetMark(seg, i)) {
+ if (nonmovingGetMark(seg, i) == nonmovingMarkEpoch) {
StgClosure *c = (StgClosure *) nonmovingSegmentGetBlock(seg, i);
if (collect_live_words)
census.n_live_words += closure_sizeW(c);
@@ -88,28 +88,51 @@ nonmovingAllocatorCensus(struct NonmovingAllocator *alloc)
}
-void nonmovingPrintAllocatorCensus()
+static void print_alloc_census(int i, struct NonmovingAllocCensus census)
{
- if (!RtsFlags.GcFlags.useNonmoving)
- return;
+ uint32_t blk_size = 1 << (i + NONMOVING_ALLOCA0);
+ int sz_min = 1 << (i + NONMOVING_ALLOCA0 - 1);
+ int sz_max = 1 << (i + NONMOVING_ALLOCA0);
+ (void) sz_min; (void) sz_max;
- for (int i=0; i < NONMOVING_ALLOCA_CNT; i++) {
- struct NonmovingAllocCensus census =
- nonmovingAllocatorCensus(nonmovingHeap.allocators[i]);
-
- uint32_t blk_size = 1 << (i + NONMOVING_ALLOCA0);
+ if (census.collected_live_words) {
// We define occupancy as the fraction of space that is used for useful
// data (that is, live and not slop).
double occupancy = 100.0 * census.n_live_words * sizeof(W_)
/ (census.n_live_blocks * blk_size);
if (census.n_live_blocks == 0) occupancy = 100;
(void) occupancy; // silence warning if !DEBUG
- debugTrace(DEBUG_nonmoving_gc, "Allocator %d (%d bytes - %d bytes): "
- "%d active segs, %d filled segs, %d live blocks, %d live words "
- "(%2.1f%% occupancy)",
- i, 1 << (i + NONMOVING_ALLOCA0 - 1), 1 << (i + NONMOVING_ALLOCA0),
- census.n_active_segs, census.n_filled_segs, census.n_live_blocks, census.n_live_words,
+ debugTrace(DEBUG_nonmoving_gc,
+ "Allocator %d (%d bytes - %d bytes): "
+ "%"PRIu32" active segs, %"PRIu32" filled segs, %"PRIu32" live blocks, "
+ "%"PRIu32" live words (%2.1f%% occupancy)",
+ i, sz_min, sz_max,
+ census.n_active_segs,
+ census.n_filled_segs,
+ census.n_live_blocks,
+ census.n_live_words,
occupancy);
+ } else {
+ debugTrace(DEBUG_nonmoving_gc,
+ "Allocator %d (%d bytes - %d bytes): "
+ "%"PRIu32" active segs, %"PRIu32" filled segs, %"PRIu32" live blocks",
+ i, sz_min, sz_max,
+ census.n_active_segs,
+ census.n_filled_segs,
+ census.n_live_blocks);
+ }
+}
+
+void nonmovingPrintAllocatorCensus(bool collect_live_words)
+{
+ if (!RtsFlags.GcFlags.useNonmoving)
+ return;
+
+ for (int i=0; i < NONMOVING_ALLOCA_CNT; i++) {
+ struct NonmovingAllocCensus census =
+ nonmovingAllocatorCensus_(nonmovingHeap.allocators[i], collect_live_words);
+
+ print_alloc_census(i, census);
}
}
diff --git a/rts/sm/NonMovingCensus.h b/rts/sm/NonMovingCensus.h
index 7a66dc9b69..988df290ea 100644
--- a/rts/sm/NonMovingCensus.h
+++ b/rts/sm/NonMovingCensus.h
@@ -11,6 +11,7 @@
#include "NonMoving.h"
struct NonmovingAllocCensus {
+ bool collected_live_words;
uint32_t n_active_segs;
uint32_t n_filled_segs;
uint32_t n_live_blocks;
@@ -24,5 +25,5 @@ nonmovingAllocatorCensusWithWords(struct NonmovingAllocator *alloc);
struct NonmovingAllocCensus
nonmovingAllocatorCensus(struct NonmovingAllocator *alloc);
-void nonmovingPrintAllocatorCensus(void);
+void nonmovingPrintAllocatorCensus(bool collect_live_words);
void nonmovingTraceAllocatorCensus(void);