WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content

Commit 6a55e52

Browse files
authored
document metrics from GC_Num; rename one metric from GC_Num to match the name used by the equivalent C struct (JuliaLang#60115)
See PR title. I plan to clean up the GC metrics code a bit more in subsequent PRs.
1 parent 29a4bbf commit 6a55e52

File tree

2 files changed

+113
-31
lines changed

2 files changed

+113
-31
lines changed

base/timing.jl

Lines changed: 69 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -2,35 +2,76 @@
22

33
# This type must be kept in sync with the C struct in src/gc-interface.h
44
struct GC_Num
5-
allocd ::Int64 # GC internal
6-
deferred_alloc ::Int64 # GC internal
7-
freed ::Int64 # GC internal
8-
malloc ::Int64
9-
realloc ::Int64
10-
poolalloc ::Int64
11-
bigalloc ::Int64
12-
freecall ::Int64
13-
total_time ::Int64
14-
total_allocd ::Int64 # GC internal
15-
collect ::Csize_t # GC internal
16-
pause ::Cint
17-
full_sweep ::Cint
18-
max_pause ::Int64
19-
max_memory ::Int64
20-
time_to_safepoint ::Int64
21-
max_time_to_safepoint ::Int64
22-
total_time_to_safepoint ::Int64
23-
sweep_time ::Int64
24-
mark_time ::Int64
25-
stack_pool_sweep_time ::Int64
26-
total_sweep_time ::Int64
27-
total_sweep_page_walk_time ::Int64
28-
total_sweep_madvise_time ::Int64
29-
total_sweep_free_mallocd_memory_time ::Int64
30-
total_mark_time ::Int64
5+
# (GC Internal) Number of allocated bytes since the last collection. This field is reset
6+
# after the end of every garbage collection cycle, so it will always be zero if observed
7+
# during execution of Julia user code
8+
allocd::Int64
9+
# (GC Internal) Number of allocated bytes within a `gc_disable/gc_enable` block. This field is
10+
# reset after every garbage collection cycle and will always be zero in case of no use
11+
# of `gc_disable/gc_enable` blocks
12+
deferred_alloc::Int64
13+
# (GC Internal) Number of bytes freed bytes in the current collection cycle. This field is
14+
# reset after every garbage collection cycle and will always be zero when observed
15+
# during execution of Julia user code. It's incremented as memory is reclaimed during a collection,
16+
# used to gather some statistics within the collection itself and reset at the end of a GC cycle.
17+
freed::Int64
18+
# Number of `malloc/calloc` calls (never reset by the runtime)
19+
malloc::Int64
20+
# Number of `realloc` calls (never reset by the runtime)
21+
realloc::Int64
22+
# Number of pool allocation calls (never reset by the runtime)
23+
# NOTE: Julia's stock GC uses an internal (pool) allocator for objects up to 2032 bytes.
24+
# Larger objects are allocated through `malloc/calloc`.
25+
poolalloc::Int64
26+
# Number of allocations for "big objects" (non-array objects larger than 2032 bytes)
27+
# (never reset by the runtime)
28+
bigalloc::Int64
29+
# Number of `free` calls (never reset by the runtime)
30+
freecall::Int64
31+
# Total time spent in garbage collection (never reset by the runtime)
32+
total_time::Int64
33+
# (GC internal) Total number of bytes allocated since the program started
34+
total_allocd::Int64
35+
# (GC internal) Per-thread allocation quota before triggering a GC
36+
# NOTE: This field is no longer used by the heuristics in the stock GC
37+
interval::Csize_t
38+
# Duration of the last GC pause in nanoseconds
39+
pause::Cint
40+
# Number of full GC sweeps completed so far (never reset by the runtime)
41+
full_sweep::Cint
42+
# Maximum pause duration observed so far in nanoseconds
43+
max_pause::Int64
44+
# Maximum number of bytes allocated any point in time.
45+
# NOTE: This is aggregated over objects, not pages
46+
max_memory::Int64
47+
# Time taken to reach a safepoint in the last GC cycle in nanoseconds
48+
time_to_safepoint::Int64
49+
# Maximum time taken to reach a safepoint across all GCs in nanoseconds
50+
max_time_to_safepoint::Int64
51+
# Total time taken to reach safepoints across all GCs in nanoseconds
52+
total_time_to_safepoint::Int64
53+
# Time spent in the last GC sweeping phase in nanoseconds
54+
sweep_time::Int64
55+
# Time spent in the last GC marking phase in nanoseconds
56+
mark_time::Int64
57+
# Time spent sweeping stack pools in the last GC in nanoseconds
58+
stack_pool_sweep_time::Int64
59+
# Total time spent in sweeping phase across all GCs in nanoseconds
60+
total_sweep_time::Int64
61+
# Total time spent walking pool allocated pages during sweeping phase across all GCs in nanoseconds
62+
total_sweep_page_walk_time::Int64
63+
# Total time spent in madvise calls during sweeping phase across all GCs in nanoseconds
64+
total_sweep_madvise_time::Int64
65+
# Total time spent in freeing malloc'd memory during sweeping phase across all GCs in nanoseconds
66+
total_sweep_free_mallocd_memory_time::Int64
67+
# Total time spent in marking phase across all GCs in nanoseconds
68+
total_mark_time::Int64
69+
# Total time spent sweeping stack pools across all GCs in nanoseconds
3170
total_stack_pool_sweep_time::Int64
32-
last_full_sweep ::Int64
33-
last_incremental_sweep ::Int64
71+
# Timestamp of the last full GC sweep in nanoseconds
72+
last_full_sweep::Int64
73+
# Timestamp of the last incremental GC sweep in nanoseconds
74+
last_incremental_sweep::Int64
3475
end
3576

3677
gc_num() = ccall(:jl_gc_num, GC_Num, ())

src/gc-interface.h

Lines changed: 44 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,34 +26,75 @@ struct _jl_genericmemory_t;
2626

2727
// This struct must be kept in sync with the Julia type of the same name in base/timing.jl
2828
typedef struct {
29+
// (GC Internal) Number of allocated bytes since the last collection. This field is reset
30+
// after the end of every garbage collection cycle, so it will always be zero if observed
31+
// during execution of Julia user code
2932
int64_t allocd;
33+
// (GC Internal) Number of allocated bytes within a `gc_disable/gc_enable` block. This field is
34+
// reset after every garbage collection cycle and will always be zero in case of no use
35+
// of `gc_disable/gc_enable` blocks
3036
int64_t deferred_alloc;
37+
// (GC Internal) Number of bytes freed bytes in the current collection cycle. This field is
38+
// reset after every garbage collection cycle and will always be zero when observed
39+
// during execution of Julia user code. It's incremented as memory is reclaimed during a collection,
40+
// used to gather some statistics within the collection itself and reset at the end of a GC cycle.
3141
int64_t freed;
42+
// Number of `malloc/calloc` calls (never reset by the runtime)
3243
uint64_t malloc;
44+
// Number of `realloc` calls (never reset by the runtime)
3345
uint64_t realloc;
46+
// Number of pool allocation calls (never reset by the runtime)
47+
// NOTE: Julia's stock GC uses an internal (pool) allocator for objects up to 2032 bytes.
48+
// Larger objects are allocated through `malloc/calloc`.
3449
uint64_t poolalloc;
50+
// Number of allocations for "big objects" (non-array objects larger than 2032 bytes)
51+
// (never reset by the runtime)
3552
uint64_t bigalloc;
53+
// Number of `free` calls (never reset by the runtime)
3654
uint64_t freecall;
55+
// Total time spent in garbage collection (never reset by the runtime)
3756
uint64_t total_time;
57+
// (GC internal) Total number of bytes allocated since the program started
3858
uint64_t total_allocd;
59+
// (GC internal) Per-thread allocation quota before triggering a GC
60+
// NOTE: This field is no longer used by the heuristics in the stock GC
3961
size_t interval;
62+
// Duration of the last GC pause in nanoseconds
4063
int pause;
64+
// Number of full GC sweeps completed so far (never reset by the runtime)
4165
int full_sweep;
66+
// Maximum pause duration observed so far in nanoseconds
4267
uint64_t max_pause;
68+
// Maximum number of bytes allocated any point in time.
69+
// NOTE: This is aggregated over objects, not pages
4370
uint64_t max_memory;
71+
// Time taken to reach a safepoint in the last GC cycle in nanoseconds
4472
uint64_t time_to_safepoint;
73+
// Maximum time taken to reach a safepoint across all GCs in nanoseconds
4574
uint64_t max_time_to_safepoint;
75+
// Total time taken to reach safepoints across all GCs in nanoseconds
4676
uint64_t total_time_to_safepoint;
77+
// Time spent in the last GC sweeping phase in nanoseconds
4778
uint64_t sweep_time;
79+
// Time spent in the last GC marking phase in nanoseconds
4880
uint64_t mark_time;
81+
// Time spent sweeping stack pools in the last GC in nanoseconds
4982
uint64_t stack_pool_sweep_time;
83+
// Total time spent in sweeping phase across all GCs in nanoseconds
5084
uint64_t total_sweep_time;
51-
uint64_t total_sweep_page_walk_time;
52-
uint64_t total_sweep_madvise_time;
53-
uint64_t total_sweep_free_mallocd_memory_time;
85+
// Total time spent walking pool allocated pages during sweeping phase across all GCs in nanoseconds
86+
uint64_t total_sweep_page_walk_time;
87+
// Total time spent in madvise calls during sweeping phase across all GCs in nanoseconds
88+
uint64_t total_sweep_madvise_time;
89+
// Total time spent in freeing malloc'd memory during sweeping phase across all GCs in nanoseconds
90+
uint64_t total_sweep_free_mallocd_memory_time;
91+
// Total time spent in marking phase across all GCs in nanoseconds
5492
uint64_t total_mark_time;
93+
// Total time spent sweeping stack pools across all GCs in nanoseconds
5594
uint64_t total_stack_pool_sweep_time;
95+
// Timestamp of the last full GC sweep in nanoseconds
5696
uint64_t last_full_sweep;
97+
// Timestamp of the last incremental GC sweep in nanoseconds
5798
uint64_t last_incremental_sweep;
5899
} jl_gc_num_t;
59100

0 commit comments

Comments
 (0)