Skip to content

Commit db6a85b

Browse files
d-nettoRAI CI (GitHub Action Automation)
authored andcommitted
Metric for number of live bytes in the pool allocator (JuliaLang#51151)
1 parent 2be3df9 commit db6a85b

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
@@ -746,6 +746,7 @@ int prev_sweep_full = 1;
746746
int under_pressure = 0;
747747

748748
// Full collection heuristics
749+
static int64_t pool_live_bytes = 0;
749750
static int64_t live_bytes = 0;
750751
static int64_t promoted_bytes = 0;
751752
static int64_t last_full_live = 0; // live_bytes after last full collection
@@ -1499,6 +1500,7 @@ static jl_taggedvalue_t **gc_sweep_page(jl_gc_pool_t *p, jl_gc_pagemeta_t **allo
14991500
}
15001501
gc_time_count_page(freedall, pg_skpd);
15011502
gc_num.freed += (nfree - old_nfree) * osize;
1503+
pool_live_bytes += GC_PAGE_SZ - GC_PAGE_OFFSET - nfree * osize;
15021504
return pfl;
15031505
}
15041506

@@ -3098,6 +3100,11 @@ JL_DLLEXPORT int64_t jl_gc_sync_total_bytes(int64_t offset) JL_NOTSAFEPOINT
30983100
return newtb - oldtb;
30993101
}
31003102

3103+
JL_DLLEXPORT int64_t jl_gc_pool_live_bytes(void)
3104+
{
3105+
return pool_live_bytes;
3106+
}
3107+
31013108
JL_DLLEXPORT int64_t jl_gc_live_bytes(void)
31023109
{
31033110
return live_bytes;
@@ -3300,6 +3307,7 @@ static int _jl_gc_collect(jl_ptls_t ptls, jl_gc_collection_t collection)
33003307
promoted_bytes = 0;
33013308
}
33023309
scanned_bytes = 0;
3310+
pool_live_bytes = 0;
33033311
// 6. start sweeping
33043312
uint64_t start_sweep_time = jl_hrtime();
33053313
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)