From 4b7c0d64c805ca0e7d98c45736c0dd514ad2610d Mon Sep 17 00:00:00 2001 From: Malte Sandstede Date: Thu, 6 Jul 2023 20:45:02 +0200 Subject: [PATCH] Add GC metric `last_incremental_sweep` (#50190) * Add GC metric `last_incremental_sweep` * Update gc.c * Update gc.c --- base/timing.jl | 1 + src/gc.c | 3 +++ src/gc.h | 1 + 3 files changed, 5 insertions(+) diff --git a/base/timing.jl b/base/timing.jl index d089a43071e78..aeca790bce7e9 100644 --- a/base/timing.jl +++ b/base/timing.jl @@ -25,6 +25,7 @@ struct GC_Num total_sweep_time ::Int64 total_mark_time ::Int64 last_full_sweep ::Int64 + last_incremental_sweep ::Int64 end gc_num() = ccall(:jl_gc_num, GC_Num, ()) diff --git a/src/gc.c b/src/gc.c index 7d847195dce8c..d3edbdda23939 100644 --- a/src/gc.c +++ b/src/gc.c @@ -3302,6 +3302,9 @@ static int _jl_gc_collect(jl_ptls_t ptls, jl_gc_collection_t collection) if (sweep_full) { gc_num.last_full_sweep = gc_end_time; } + else { + gc_num.last_incremental_sweep = gc_end_time; + } size_t heap_size = jl_atomic_load_relaxed(&gc_heap_stats.heap_size); double target_allocs = 0.0; diff --git a/src/gc.h b/src/gc.h index 4bfe5dc328e9d..1328ef88c2d7c 100644 --- a/src/gc.h +++ b/src/gc.h @@ -83,6 +83,7 @@ typedef struct { uint64_t total_sweep_time; uint64_t total_mark_time; uint64_t last_full_sweep; + uint64_t last_incremental_sweep; } jl_gc_num_t; // Array chunks (work items representing suffixes of