Skip to content

Commit 9ae2826

Browse files
d-nettokpamnany
authored andcommitted
Metric for number of live bytes in the pool allocator (JuliaLang#51151)
1 parent 19dd1e0 commit 9ae2826

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
@@ -849,6 +849,7 @@ int prev_sweep_full = 1;
849849
#define inc_sat(v,s) v = (v) >= s ? s : (v)+1
850850

851851
// Full collection heuristics
852+
static int64_t pool_live_bytes = 0;
852853
static int64_t live_bytes = 0;
853854
static int64_t promoted_bytes = 0;
854855
static int64_t last_live_bytes = 0; // live_bytes at last collection
@@ -1654,6 +1655,7 @@ static jl_taggedvalue_t **sweep_page(jl_gc_pool_t *p, jl_gc_pagemeta_t *pg, jl_t
16541655
done:
16551656
gc_time_count_page(freedall, pg_skpd);
16561657
gc_num.freed += (nfree - old_nfree) * osize;
1658+
pool_live_bytes += GC_PAGE_SZ - GC_PAGE_OFFSET - nfree * osize;
16571659
return pfl;
16581660
}
16591661

@@ -3298,6 +3300,11 @@ JL_DLLEXPORT int64_t jl_gc_sync_total_bytes(int64_t offset) JL_NOTSAFEPOINT
32983300
return newtb - oldtb;
32993301
}
33003302

3303+
JL_DLLEXPORT int64_t jl_gc_pool_live_bytes(void)
3304+
{
3305+
return pool_live_bytes;
3306+
}
3307+
33013308
JL_DLLEXPORT int64_t jl_gc_live_bytes(void)
33023309
{
33033310
return live_bytes;
@@ -3551,6 +3558,7 @@ static int _jl_gc_collect(jl_ptls_t ptls, jl_gc_collection_t collection)
35513558
}
35523559
scanned_bytes = 0;
35533560
// 5. start sweeping
3561+
pool_live_bytes = 0;
35543562
uint64_t start_sweep_time = jl_hrtime();
35553563
JL_PROBE_GC_SWEEP_BEGIN(sweep_full);
35563564
sweep_weak_refs();

src/jl_exported_funcs.inc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,7 @@
177177
XX(jl_gc_get_max_memory) \
178178
XX(jl_gc_internal_obj_base_ptr) \
179179
XX(jl_gc_is_enabled) \
180+
XX(jl_gc_pool_live_bytes) \
180181
XX(jl_gc_live_bytes) \
181182
XX(jl_gc_managed_malloc) \
182183
XX(jl_gc_managed_realloc) \

0 commit comments

Comments
 (0)