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

Add new GC STATS (max memory used, and max pause time) #44955

Merged
merged 3 commits into from
Apr 27, 2022
Merged
Show file tree
Hide file tree
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
2 changes: 2 additions & 0 deletions base/timing.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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, ())
Expand Down
10 changes: 10 additions & 0 deletions src/gc.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions src/gc.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down