diff --git a/base/timing.jl b/base/timing.jl index c7870ac491169..4f5af767c5b2a 100644 --- a/base/timing.jl +++ b/base/timing.jl @@ -16,6 +16,8 @@ struct GC_Num collect ::Csize_t # GC internal pause ::Cint full_sweep ::Cint + max_pause ::Int64 + max_memory ::Int64 end gc_num() = ccall(:jl_gc_num, GC_Num, ()) diff --git a/src/gc.c b/src/gc.c index d4af5f443764c..10a0a89e12d88 100644 --- a/src/gc.c +++ b/src/gc.c @@ -3225,6 +3225,11 @@ static int _jl_gc_collect(jl_ptls_t ptls, jl_gc_collection_t collection) gc_time_sweep_pause(gc_end_t, actual_allocd, live_bytes, estimate_freed, sweep_full); gc_num.full_sweep += sweep_full; + uint64_t max_memory = last_live_bytes + gc_num.allocd; + if (max_memory > gc_num.max_memory) { + gc_num.max_memory = max_memory; + } + gc_num.allocd = 0; last_live_bytes = live_bytes; live_bytes += -gc_num.freed + gc_num.since_sweep; @@ -3244,6 +3249,9 @@ static int _jl_gc_collect(jl_ptls_t ptls, jl_gc_collection_t collection) gc_num.total_time += pause; gc_num.since_sweep = 0; gc_num.freed = 0; + if (pause > gc_num.max_pause) { + gc_num.max_pause = pause; + } reset_thread_gc_counts(); return recollect; @@ -3393,6 +3401,8 @@ void jl_gc_init(void) gc_num.interval = default_collect_interval; last_long_collect_interval = default_collect_interval; gc_num.allocd = 0; + gc_num.max_pause = 0; + gc_num.max_memory = 0; #ifdef _P64 // on a big memory machine, set max_collect_interval to totalmem / ncores / 2 diff --git a/src/gc.h b/src/gc.h index d50e32c1a0444..858cafa6cec07 100644 --- a/src/gc.h +++ b/src/gc.h @@ -72,6 +72,8 @@ typedef struct { size_t interval; int pause; int full_sweep; + uint64_t max_pause; + uint64_t max_memory; } jl_gc_num_t; enum {