1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-06-06 04:00:26 +02:00

Add allocation counter to prepare_gc event

Adapt all users
This commit is contained in:
Andy Wingo 2025-05-16 21:57:10 +02:00
parent f5edbc278b
commit 8a157bc616
9 changed files with 21 additions and 12 deletions

View file

@ -26,6 +26,7 @@ struct gc_basic_stats {
size_t max_heap_size;
size_t live_data_size;
size_t max_live_data_size;
uint64_t allocation_counter_at_last_gc;
struct gc_latency pause_times;
};
@ -68,12 +69,14 @@ static inline void gc_basic_stats_waiting_for_stop(void *data) {}
static inline void gc_basic_stats_mutators_stopped(void *data) {}
static inline void gc_basic_stats_prepare_gc(void *data,
enum gc_collection_kind kind) {
enum gc_collection_kind kind,
uint64_t allocation_counter) {
struct gc_basic_stats *stats = data;
if (kind == GC_COLLECTION_MINOR)
stats->minor_collection_count++;
else
stats->major_collection_count++;
stats->allocation_counter_at_last_gc = allocation_counter;
}
static inline void gc_basic_stats_roots_traced(void *data) {}

View file

@ -36,10 +36,11 @@ static inline void gc_event_listener_chain_mutators_stopped(void *data) {
chain->tail.mutators_stopped(chain->tail_data);
}
static inline void
gc_event_listener_chain_prepare_gc(void *data, enum gc_collection_kind kind) {
gc_event_listener_chain_prepare_gc(void *data, enum gc_collection_kind kind,
uint64_t counter) {
struct gc_event_listener_chain *chain = data;
chain->head.prepare_gc(chain->head_data, kind);
chain->tail.prepare_gc(chain->tail_data, kind);
chain->head.prepare_gc(chain->head_data, kind, counter);
chain->tail.prepare_gc(chain->tail_data, kind, counter);
}
static inline void gc_event_listener_chain_roots_traced(void *data) {
struct gc_event_listener_chain *chain = data;

View file

@ -8,7 +8,8 @@ struct gc_event_listener {
void (*requesting_stop)(void *data);
void (*waiting_for_stop)(void *data);
void (*mutators_stopped)(void *data);
void (*prepare_gc)(void *data, enum gc_collection_kind kind);
void (*prepare_gc)(void *data, enum gc_collection_kind kind,
uint64_t allocation_counter);
void (*roots_traced)(void *data);
void (*heap_traced)(void *data);
void (*ephemerons_traced)(void *data);

View file

@ -45,9 +45,10 @@ LTTNG_UST_TRACEPOINT_EVENT_INSTANCE(
whippet, tracepoint, whippet, mutators_stopped, LTTNG_UST_TP_ARGS())
LTTNG_UST_TRACEPOINT_EVENT(
whippet, prepare_gc,
LTTNG_UST_TP_ARGS(int, gc_kind),
LTTNG_UST_TP_ARGS(int, gc_kind, uint64_t, allocation_counter),
LTTNG_UST_TP_FIELDS(
lttng_ust_field_enum(whippet, gc_kind, int, gc_kind, gc_kind)))
lttng_ust_field_enum(whippet, gc_kind, int, gc_kind, gc_kind)
lttng_ust_field_integer(uint64_t, allocation_counter, allocation_counter)))
LTTNG_UST_TRACEPOINT_EVENT_INSTANCE(
whippet, tracepoint, whippet, roots_traced, LTTNG_UST_TP_ARGS())
LTTNG_UST_TRACEPOINT_EVENT_INSTANCE(

View file

@ -8,7 +8,8 @@ static inline void gc_null_event_listener_requesting_stop(void *data) {}
static inline void gc_null_event_listener_waiting_for_stop(void *data) {}
static inline void gc_null_event_listener_mutators_stopped(void *data) {}
static inline void gc_null_event_listener_prepare_gc(void *data,
enum gc_collection_kind) {}
enum gc_collection_kind,
uint64_t) {}
static inline void gc_null_event_listener_roots_traced(void *data) {}
static inline void gc_null_event_listener_heap_traced(void *data) {}
static inline void gc_null_event_listener_ephemerons_traced(void *data) {}

View file

@ -505,7 +505,7 @@ static void on_collection_event(GC_EventType event) {
}
case GC_EVENT_MARK_START:
HEAP_EVENT(mutators_stopped);
HEAP_EVENT(prepare_gc, GC_COLLECTION_MAJOR);
HEAP_EVENT(prepare_gc, GC_COLLECTION_MAJOR, GC_get_total_bytes());
break;
case GC_EVENT_MARK_END:
HEAP_EVENT(roots_traced);

View file

@ -792,7 +792,7 @@ collect(struct gc_mutator *mut, enum gc_collection_kind requested_kind) {
enum gc_collection_kind gc_kind =
determine_collection_kind(heap, requested_kind);
int is_minor = gc_kind == GC_COLLECTION_MINOR;
HEAP_EVENT(heap, prepare_gc, gc_kind);
HEAP_EVENT(heap, prepare_gc, gc_kind, heap->total_allocated_bytes_at_last_gc);
nofl_space_prepare_gc(nofl_space, gc_kind);
large_object_space_start_gc(lospace, is_minor);
gc_extern_space_start_gc(exspace, is_minor);

View file

@ -905,11 +905,11 @@ collect(struct gc_mutator *mut, enum gc_collection_kind requested_kind) {
heap->is_minor_collection =
#endif
GC_GENERATIONAL ? gc_kind == GC_COLLECTION_MINOR : 0;
HEAP_EVENT(heap, prepare_gc, gc_kind);
uint64_t *counter_loc = &heap->total_allocated_bytes_at_last_gc;
copy_space_add_to_allocation_counter(heap_allocation_space(heap),
counter_loc);
large_object_space_add_to_allocation_counter(lospace, counter_loc);
HEAP_EVENT(heap, prepare_gc, gc_kind, *counter_loc);
copy_spaces_start_gc(heap, is_minor_gc);
large_object_space_start_gc(lospace, is_minor_gc);
gc_extern_space_start_gc(exspace, is_minor_gc);

View file

@ -395,7 +395,6 @@ static void collect(struct gc_mutator *mut) {
HEAP_EVENT(heap, requesting_stop);
HEAP_EVENT(heap, waiting_for_stop);
HEAP_EVENT(heap, mutators_stopped);
HEAP_EVENT(heap, prepare_gc, GC_COLLECTION_COMPACTING);
struct semi_space *semi = heap_semi_space(heap);
struct large_object_space *large = heap_large_object_space(heap);
@ -403,6 +402,9 @@ static void collect(struct gc_mutator *mut) {
uint64_t *counter_loc = &heap->total_allocated_bytes_at_last_gc;
semi_space_add_to_allocation_counter(semi, counter_loc);
large_object_space_add_to_allocation_counter(large, counter_loc);
HEAP_EVENT(heap, prepare_gc, GC_COLLECTION_COMPACTING, *counter_loc);
large_object_space_start_gc(large, 0);
gc_extern_space_start_gc(heap->extern_space, 0);
flip(semi);