Skip to content

Commit 1d089b7

Browse files
committed
Add heap size stat
1 parent 0ee0571 commit 1d089b7

File tree

2 files changed

+4
-0
lines changed

2 files changed

+4
-0
lines changed

src/gc.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1193,6 +1193,7 @@ void jl_gc_reset_alloc_count(void) JL_NOTSAFEPOINT
11931193
{
11941194
combine_thread_gc_counts(&gc_num);
11951195
live_bytes += (gc_num.deferred_alloc + gc_num.allocd);
1196+
jl_timing_counter_inc(JL_TIMING_COUNTER_HeapSize, gc_num.deferred_alloc + gc_num.allocd);
11961197
gc_num.allocd = 0;
11971198
gc_num.deferred_alloc = 0;
11981199
reset_thread_gc_counts();
@@ -3343,6 +3344,7 @@ static int _jl_gc_collect(jl_ptls_t ptls, jl_gc_collection_t collection)
33433344

33443345
last_live_bytes = live_bytes;
33453346
live_bytes += -gc_num.freed + gc_num.allocd;
3347+
jl_timing_counter_inc(JL_TIMING_COUNTER_HeapSize, -gc_num.freed + gc_num.allocd);
33463348

33473349
if (collection == JL_GC_AUTO) {
33483350
//If we aren't freeing enough or are seeing lots and lots of pointers let it increase faster
@@ -3782,6 +3784,7 @@ static void *gc_managed_realloc_(jl_ptls_t ptls, void *d, size_t sz, size_t olds
37823784
if (jl_astaggedvalue(owner)->bits.gc == GC_OLD_MARKED) {
37833785
ptls->gc_cache.perm_scanned_bytes += allocsz - oldsz;
37843786
live_bytes += allocsz - oldsz;
3787+
jl_timing_counter_inc(JL_TIMING_COUNTER_HeapSize, allocsz - oldsz);
37853788
}
37863789
else if (allocsz < oldsz)
37873790
jl_atomic_store_relaxed(&ptls->gc_num.freed,

src/timing.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,7 @@ void jl_timing_puts(jl_timing_block_t *cur_block, const char *str);
193193

194194
#define JL_TIMING_COUNTERS \
195195
X(Invalidations) \
196+
X(HeapSize) \
196197

197198

198199
enum jl_timing_owners {

0 commit comments

Comments
 (0)