@@ -648,6 +648,8 @@ typedef struct rb_objspace {
648648 struct timespec ruby_thread_sweep_cpu_start_time ;
649649 struct timespec ruby_thread_sweep_wall_start_time ;
650650#endif
651+ size_t pages_swept_by_sweep_thread ;
652+ size_t pages_swept_by_sweep_thread_had_deferred_free_objects ;
651653
652654 /* Weak references */
653655 size_t weak_references_count ;
@@ -4556,6 +4558,10 @@ gc_pre_sweep_page(rb_objspace_t *objspace, rb_heap_t *heap, struct heap_page *pa
45564558 }
45574559 p += BITS_BITLENGTH * BASE_SLOT_SIZE ;
45584560 }
4561+ objspace -> profile .pages_swept_by_sweep_thread ++ ;
4562+ if (page -> pre_deferred_free_slots > 0 ) {
4563+ objspace -> profile .pages_swept_by_sweep_thread_had_deferred_free_objects ++ ;
4564+ }
45594565 psweep_debug (1 , "[sweep] gc_pre_sweep_page(heap:%p page:%p) done, deferred free:%d\n" , heap , page , page -> pre_deferred_free_slots );
45604566}
45614567
@@ -9124,6 +9130,8 @@ enum gc_stat_sym {
91249130 gc_stat_sym_remembered_wb_unprotected_objects_limit ,
91259131 gc_stat_sym_old_objects ,
91269132 gc_stat_sym_old_objects_limit ,
9133+ gc_stat_sym_pages_swept_by_sweep_thread ,
9134+ gc_stat_sym_pages_swept_by_sweep_thread_had_deferred_free_objects ,
91279135#if RGENGC_ESTIMATE_OLDMALLOC
91289136 gc_stat_sym_oldmalloc_increase_bytes ,
91299137 gc_stat_sym_oldmalloc_increase_bytes_limit ,
@@ -9175,6 +9183,8 @@ setup_gc_stat_symbols(void)
91759183 S (remembered_wb_unprotected_objects_limit );
91769184 S (old_objects );
91779185 S (old_objects_limit );
9186+ S (pages_swept_by_sweep_thread );
9187+ S (pages_swept_by_sweep_thread_had_deferred_free_objects );
91789188#if RGENGC_ESTIMATE_OLDMALLOC
91799189 S (oldmalloc_increase_bytes );
91809190 S (oldmalloc_increase_bytes_limit );
@@ -9257,6 +9267,8 @@ rb_gc_impl_stat(void *objspace_ptr, VALUE hash_or_sym)
92579267 SET (remembered_wb_unprotected_objects_limit , objspace -> rgengc .uncollectible_wb_unprotected_objects_limit );
92589268 SET (old_objects , objspace -> rgengc .old_objects );
92599269 SET (old_objects_limit , objspace -> rgengc .old_objects_limit );
9270+ SET (pages_swept_by_sweep_thread , objspace -> profile .pages_swept_by_sweep_thread );
9271+ SET (pages_swept_by_sweep_thread_had_deferred_free_objects , objspace -> profile .pages_swept_by_sweep_thread_had_deferred_free_objects );
92609272#if RGENGC_ESTIMATE_OLDMALLOC
92619273 SET (oldmalloc_increase_bytes , objspace -> malloc_counters .oldmalloc_increase );
92629274 SET (oldmalloc_increase_bytes_limit , objspace -> rgengc .oldmalloc_increase_limit );
0 commit comments