Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Metric for number of live bytes in the pool allocator #51151

Merged
merged 1 commit into from
Sep 3, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Export pool live bytes metric
d-netto committed Sep 1, 2023
commit f3324d04e993e958584bd85807bef31e4187f0ec
8 changes: 8 additions & 0 deletions src/gc.c
Original file line number Diff line number Diff line change
@@ -753,6 +753,7 @@ int prev_sweep_full = 1;
int under_pressure = 0;

// Full collection heuristics
static int64_t pool_live_bytes = 0;
static int64_t live_bytes = 0;
static int64_t promoted_bytes = 0;
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
}
gc_time_count_page(freedall, pg_skpd);
gc_num.freed += (nfree - old_nfree) * osize;
pool_live_bytes += GC_PAGE_SZ - GC_PAGE_OFFSET - nfree * osize;
return pfl;
}

@@ -3108,6 +3110,11 @@ JL_DLLEXPORT int64_t jl_gc_sync_total_bytes(int64_t offset) JL_NOTSAFEPOINT
return newtb - oldtb;
}

JL_DLLEXPORT int64_t jl_gc_pool_live_bytes(void)
{
return pool_live_bytes;
}

JL_DLLEXPORT int64_t jl_gc_live_bytes(void)
{
return live_bytes;
@@ -3269,6 +3276,7 @@ static int _jl_gc_collect(jl_ptls_t ptls, jl_gc_collection_t collection)
promoted_bytes = 0;
}
scanned_bytes = 0;
pool_live_bytes = 0;
// 6. start sweeping
uint64_t start_sweep_time = jl_hrtime();
JL_PROBE_GC_SWEEP_BEGIN(sweep_full);
1 change: 1 addition & 0 deletions src/jl_exported_funcs.inc
Original file line number Diff line number Diff line change
@@ -176,6 +176,7 @@
XX(jl_gc_internal_obj_base_ptr) \
XX(jl_gc_is_enabled) \
XX(jl_gc_is_in_finalizer) \
XX(jl_gc_pool_live_bytes) \
XX(jl_gc_live_bytes) \
XX(jl_gc_managed_malloc) \
XX(jl_gc_managed_realloc) \