Skip to content

Commit 1b46abb

Browse files
d-nettoDrvi
authored andcommitted
Metric for number of live bytes in the pool allocator (JuliaLang#51151)
1 parent f89d403 commit 1b46abb

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
@@ -748,6 +748,7 @@ int prev_sweep_full = 1;
748748
int under_pressure = 0;
749749

750750
// Full collection heuristics
751+
static int64_t pool_live_bytes = 0;
751752
static int64_t live_bytes = 0;
752753
static int64_t promoted_bytes = 0;
753754
static int64_t last_full_live = 0; // live_bytes after last full collection
@@ -1501,6 +1502,7 @@ static jl_taggedvalue_t **gc_sweep_page(jl_gc_pool_t *p, jl_gc_pagemeta_t **allo
15011502
}
15021503
gc_time_count_page(freedall, pg_skpd);
15031504
gc_num.freed += (nfree - old_nfree) * osize;
1505+
pool_live_bytes += GC_PAGE_SZ - GC_PAGE_OFFSET - nfree * osize;
15041506
return pfl;
15051507
}
15061508

@@ -3188,6 +3190,11 @@ JL_DLLEXPORT int64_t jl_gc_sync_total_bytes(int64_t offset) JL_NOTSAFEPOINT
31883190
return newtb - oldtb;
31893191
}
31903192

3193+
JL_DLLEXPORT int64_t jl_gc_pool_live_bytes(void)
3194+
{
3195+
return pool_live_bytes;
3196+
}
3197+
31913198
JL_DLLEXPORT int64_t jl_gc_live_bytes(void)
31923199
{
31933200
return live_bytes;
@@ -3390,6 +3397,7 @@ static int _jl_gc_collect(jl_ptls_t ptls, jl_gc_collection_t collection)
33903397
promoted_bytes = 0;
33913398
}
33923399
scanned_bytes = 0;
3400+
pool_live_bytes = 0;
33933401
// 6. start sweeping
33943402
uint64_t start_sweep_time = jl_hrtime();
33953403
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)