Skip to content

Commit 37d87bc

Browse files
d-nettokpamnany
authored andcommitted
Metric for number of live bytes in the pool allocator (JuliaLang#51151)
1 parent 97115a1 commit 37d87bc

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

src/gc.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -753,6 +753,7 @@ int prev_sweep_full = 1;
753753
int under_pressure = 0;
754754

755755
// Full collection heuristics
756+
static int64_t pool_live_bytes = 0;
756757
static int64_t live_bytes = 0;
757758
static int64_t promoted_bytes = 0;
758759
static int64_t last_live_bytes = 0; // live_bytes at last collection
@@ -1530,6 +1531,7 @@ static jl_taggedvalue_t **gc_sweep_page(jl_gc_pool_t *p, jl_gc_pagemeta_t **allo
15301531
}
15311532
gc_time_count_page(freedall, pg_skpd);
15321533
gc_num.freed += (nfree - old_nfree) * osize;
1534+
pool_live_bytes += GC_PAGE_SZ - GC_PAGE_OFFSET - nfree * osize;
15331535
return pfl;
15341536
}
15351537

@@ -3123,6 +3125,11 @@ JL_DLLEXPORT int64_t jl_gc_sync_total_bytes(int64_t offset) JL_NOTSAFEPOINT
31233125
return newtb - oldtb;
31243126
}
31253127

3128+
JL_DLLEXPORT int64_t jl_gc_pool_live_bytes(void)
3129+
{
3130+
return pool_live_bytes;
3131+
}
3132+
31263133
JL_DLLEXPORT int64_t jl_gc_live_bytes(void)
31273134
{
31283135
return live_bytes;
@@ -3284,6 +3291,7 @@ static int _jl_gc_collect(jl_ptls_t ptls, jl_gc_collection_t collection)
32843291
promoted_bytes = 0;
32853292
}
32863293
scanned_bytes = 0;
3294+
pool_live_bytes = 0;
32873295
// 6. start sweeping
32883296
uint64_t start_sweep_time = jl_hrtime();
32893297
JL_PROBE_GC_SWEEP_BEGIN(sweep_full);

src/jl_exported_funcs.inc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,7 @@
176176
XX(jl_gc_internal_obj_base_ptr) \
177177
XX(jl_gc_is_enabled) \
178178
XX(jl_gc_is_in_finalizer) \
179+
XX(jl_gc_pool_live_bytes) \
179180
XX(jl_gc_live_bytes) \
180181
XX(jl_gc_managed_malloc) \
181182
XX(jl_gc_managed_realloc) \

0 commit comments

Comments
 (0)