X-Git-Url: https://git.llucax.com/software/dgc/cdgc.git/blobdiff_plain/13761bd8269f2230742d6befddf3a3154b1ee610..b5e1601adc7b579e9d2366aa2529b07ee6f47fe3:/rt/gc/cdgc/stats.d?ds=sidebyside diff --git a/rt/gc/cdgc/stats.d b/rt/gc/cdgc/stats.d index aefce42..1a2e8ef 100644 --- a/rt/gc/cdgc/stats.d +++ b/rt/gc/cdgc/stats.d @@ -157,7 +157,7 @@ struct Stats private: /// The GC instance we are collecting stats from. - .gc.GC gc = null; + .gc.GC* gc = null; /// True if statistics should be collected. bool active = false; @@ -188,13 +188,13 @@ private: /// Fill a MemoryInfo struct with the current state of the GC heap. void fill_memory_info(MemoryInfo* mem_info) { - mem_info.overhead += .gc.GC.classinfo.init.length + .gc.Gcx.sizeof - + .gc.pools.size_of + .gc.roots.size_of + .gc.ranges.size_of; + mem_info.overhead += .gc.GC.sizeof + gc.pools.elements_sizeof + + gc.roots.elements_sizeof + gc.ranges.elements_sizeof; // pools - for (size_t i = 0; i < .gc.pools.length; i++) + for (size_t i = 0; i < gc.pools.length; i++) { - auto pool = .gc.pools[i]; + auto pool = gc.pools[i]; mem_info.overhead += pool.npages * ubyte.sizeof; // the 5 bitmaps (mark, scan, free, final, noscan) mem_info.overhead += 5 * (GCBits.sizeof @@ -237,9 +237,11 @@ private: { if (this.mallocs_file is null) return; + auto ptrmap = this.malloc_info.ptrmap; + auto ptrmask_offset = (ptrmap[0] - 1) / (size_t.sizeof * 8) + 1; cstdio.fprintf(this.mallocs_file, - "%f,%f,%p,%zu,%zu,%zu,%zu,%zu,%p\n", - //0 1 2 3 4 5 6 7 8 + "%f,%f,%p,%zu,%zu,%zu,%zu,%zu,%p,%zu,%0*zX,%0*zX\n", + //0 1 2 3 4 5 6 7 8 9 10 11 this.malloc_info.timestamp, // 0 this.malloc_info.time, // 1 this.malloc_info.ptr, // 2 @@ -248,7 +250,12 @@ private: this.malloc_info.attr & .gc.BlkAttr.FINALIZE, // 5 this.malloc_info.attr & .gc.BlkAttr.NO_SCAN, // 6 this.malloc_info.attr & .gc.BlkAttr.NO_MOVE, // 7 - this.malloc_info.ptrmap); // 8 + ptrmap, // 8 + ptrmap[0] * size_t.sizeof, // 9 + size_t.sizeof, // fill length + ptrmap[1], // 10 + size_t.sizeof, // fill length + ptrmap[1 + ptrmask_offset]); // 11 // TODO: make it an option cstdio.fflush(this.mallocs_file); } @@ -286,7 +293,7 @@ public: * the program start time (in seconds since the epoch) needs to be taken to * properly add timestamps to allocations and collections. */ - static Stats opCall(.gc.GC gc) + static Stats opCall(.gc.GC* gc) { Stats this_; this_.gc = gc; @@ -295,7 +302,9 @@ public: this_.mallocs_file = this_.start_file( options.malloc_stats_file.ptr, "Timestamp,Time,Pointer,Size,Collection triggered," - "Finalize,No scan,No move,Pointer map\n"); + "Finalize,No scan,No move,Pointer map,Type size," + "Pointer map scan bitmask (first word, hexa)," + "Pointer map pointer bitmask (first word, hexa)\n"); } // collection if (options.collect_stats_file[0] != '\0') {