From 8c739b1bdc8621c06ac8f8b7fef65ce21be976b7 Mon Sep 17 00:00:00 2001 From: Kiran Date: Wed, 31 May 2023 16:16:01 -0400 Subject: [PATCH] Add GC metric `last_full_sweep` (#50018) Records the time that the last full sweep ran. --- 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 04994914049a0..691db3cbbd260 100644 --- a/base/timing.jl +++ b/base/timing.jl @@ -25,6 +25,7 @@ struct GC_Num mark_time ::Int64 total_sweep_time ::Int64 total_mark_time ::Int64 + last_full_sweep ::Int64 end gc_num() = ccall(:jl_gc_num, GC_Num, ()) diff --git a/src/gc.c b/src/gc.c index 4983570054c55..0f30e8305b78c 100644 --- a/src/gc.c +++ b/src/gc.c @@ -3283,6 +3283,9 @@ static int _jl_gc_collect(jl_ptls_t ptls, jl_gc_collection_t collection) uint64_t sweep_time = gc_end_time - start_sweep_time; gc_num.total_sweep_time += sweep_time; gc_num.sweep_time = sweep_time; + if (sweep_full) { + gc_num.last_full_sweep = gc_end_time; + } // sweeping is over // 6. if it is a quick sweep, put back the remembered objects in queued state diff --git a/src/gc.h b/src/gc.h index 7d6aff3499eae..8436a653dc32b 100644 --- a/src/gc.h +++ b/src/gc.h @@ -82,6 +82,7 @@ typedef struct { uint64_t mark_time; uint64_t total_sweep_time; uint64_t total_mark_time; + uint64_t last_full_sweep; } jl_gc_num_t; enum {