Skip to content
This repository has been archived by the owner on Oct 12, 2022. It is now read-only.

Commit

Permalink
Remove extra GC stat fields and rename remaining
Browse files Browse the repository at this point in the history
Before making stats struct and thus standardizing it, field set
it defines has to be reduced to minimal amount meaningful to
any GC implementation.
  • Loading branch information
Dicebot committed Jul 19, 2016
1 parent fb0dafb commit 4b2901c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 17 deletions.
15 changes: 5 additions & 10 deletions src/gc/impl/conservative/gc.d
Expand Up @@ -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();
Expand Down Expand Up @@ -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;
}
}
Expand All @@ -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;
}
}

Expand Down
12 changes: 5 additions & 7 deletions src/gc/stats.d
Expand Up @@ -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;
}

0 comments on commit 4b2901c

Please sign in to comment.