From 4b2901c940756270411039fad4615cb46a2ad9c4 Mon Sep 17 00:00:00 2001 From: Dicebot Date: Sat, 9 Jul 2016 23:59:29 +0300 Subject: [PATCH] Remove extra GC stat fields and rename remaining Before making stats struct and thus standardizing it, field set it defines has to be reduced to minimal amount meaningful to any GC implementation. --- src/gc/impl/conservative/gc.d | 15 +++++---------- src/gc/stats.d | 12 +++++------- 2 files changed, 10 insertions(+), 17 deletions(-) diff --git a/src/gc/impl/conservative/gc.d b/src/gc/impl/conservative/gc.d index 91cf7762f9a..9041e2126fe 100644 --- a/src/gc/impl/conservative/gc.d +++ b/src/gc/impl/conservative/gc.d @@ -1157,8 +1157,8 @@ class ConservativeGC : GC GCStats stats; getStats(stats); - debug(PRINTF) printf("poolsize = %zx, usedsize = %zx, freelistsize = %zx\n", - stats.poolsize, stats.usedsize, stats.freelistsize); + debug(PRINTF) printf("heapSize = %zx, freeSize = %zx\n", + stats.heapSize, stats.freeSize); } gcx.log_collect(); @@ -1223,11 +1223,7 @@ class ConservativeGC : GC for (size_t j = 0; j < pool.npages; j++) { Bins bin = cast(Bins)pool.pagetable[j]; - if (bin == B_FREE) - stats.freeblocks++; - else if (bin == B_PAGE) - stats.pageblocks++; - else if (bin < B_PAGE) + if (bin < B_PAGE) bsize += PAGESIZE; } } @@ -1244,9 +1240,8 @@ class ConservativeGC : GC usize = bsize - flsize; - stats.poolsize = psize; - stats.usedsize = bsize - flsize; - stats.freelistsize = flsize; + stats.usedSize = bsize - flsize; + stats.freeSize = flsize; } } diff --git a/src/gc/stats.d b/src/gc/stats.d index 2d6a01a350e..ffeed97e5c0 100644 --- a/src/gc/stats.d +++ b/src/gc/stats.d @@ -13,15 +13,13 @@ */ module gc.stats; - /** - * + * Aggregation of GC stats to be exposed via public API */ struct GCStats { - size_t poolsize; // total size of pool - size_t usedsize; // bytes allocated - size_t freeblocks; // number of blocks marked FREE - size_t freelistsize; // total of memory on free lists - size_t pageblocks; // number of blocks marked PAGE + /// total size of GC heap + size_t usedSize; + /// free bytes on the GC heap (might only get updated after a collection) + size_t freeSize; }