Skip to content

Commit e1b3c7c

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

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
@@ -1508,6 +1509,7 @@ static jl_taggedvalue_t **gc_sweep_page(jl_gc_pool_t *p, jl_gc_pagemeta_t **allo
15081509
}
15091510
gc_time_count_page(freedall, pg_skpd);
15101511
gc_num.freed += (nfree - old_nfree) * osize;
1512+
pool_live_bytes += GC_PAGE_SZ - GC_PAGE_OFFSET - nfree * osize;
15111513
return pfl;
15121514
}
15131515

@@ -3181,6 +3183,11 @@ JL_DLLEXPORT int64_t jl_gc_sync_total_bytes(int64_t offset) JL_NOTSAFEPOINT
31813183
return newtb - oldtb;
31823184
}
31833185

3186+
JL_DLLEXPORT int64_t jl_gc_pool_live_bytes(void)
3187+
{
3188+
return pool_live_bytes;
3189+
}
3190+
31843191
JL_DLLEXPORT int64_t jl_gc_live_bytes(void)
31853192
{
31863193
return live_bytes;
@@ -3383,6 +3390,7 @@ static int _jl_gc_collect(jl_ptls_t ptls, jl_gc_collection_t collection)
33833390
promoted_bytes = 0;
33843391
}
33853392
scanned_bytes = 0;
3393+
pool_live_bytes = 0;
33863394
// 6. start sweeping
33873395
uint64_t start_sweep_time = jl_hrtime();
33883396
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)