Implement heap_final_slots in GC.stat_heap

[Feature #20408]
This commit is contained in:
Peter Zhu 2025-11-19 17:15:23 -05:00
parent 83bf05427d
commit f5f69d4114
Notes: git 2025-11-19 23:26:01 +00:00
2 changed files with 5 additions and 0 deletions

View File

@ -7594,6 +7594,7 @@ enum gc_stat_heap_sym {
gc_stat_heap_sym_slot_size,
gc_stat_heap_sym_heap_live_slots,
gc_stat_heap_sym_heap_free_slots,
gc_stat_heap_sym_heap_final_slots,
gc_stat_heap_sym_heap_eden_pages,
gc_stat_heap_sym_heap_eden_slots,
gc_stat_heap_sym_total_allocated_pages,
@ -7614,6 +7615,7 @@ setup_gc_stat_heap_symbols(void)
S(slot_size);
S(heap_live_slots);
S(heap_free_slots);
S(heap_final_slots);
S(heap_eden_pages);
S(heap_eden_slots);
S(total_allocated_pages);
@ -7637,6 +7639,7 @@ stat_one_heap(rb_heap_t *heap, VALUE hash, VALUE key)
SET(slot_size, heap->slot_size);
SET(heap_live_slots, heap->total_allocated_objects - heap->total_freed_objects - heap->final_slots_count);
SET(heap_free_slots, heap->total_slots - (heap->total_allocated_objects - heap->total_freed_objects));
SET(heap_final_slots, heap->final_slots_count);
SET(heap_eden_pages, heap->total_pages);
SET(heap_eden_slots, heap->total_slots);
SET(total_allocated_pages, heap->total_allocated_pages);

View File

@ -233,6 +233,7 @@ class TestGc < Test::Unit::TestCase
assert_equal (GC::INTERNAL_CONSTANTS[:BASE_SLOT_SIZE] + GC::INTERNAL_CONSTANTS[:RVALUE_OVERHEAD]) * (2**i), stat_heap[:slot_size]
assert_operator stat_heap[:heap_live_slots], :<=, stat[:heap_live_slots]
assert_operator stat_heap[:heap_free_slots], :<=, stat[:heap_free_slots]
assert_operator stat_heap[:heap_final_slots], :<=, stat[:heap_final_slots]
assert_operator stat_heap[:heap_eden_pages], :<=, stat[:heap_eden_pages]
assert_operator stat_heap[:heap_eden_slots], :>=, 0
assert_operator stat_heap[:total_allocated_pages], :>=, 0
@ -290,6 +291,7 @@ class TestGc < Test::Unit::TestCase
assert_equal stat[:heap_live_slots], stat_heap_sum[:heap_live_slots]
assert_equal stat[:heap_free_slots], stat_heap_sum[:heap_free_slots]
assert_equal stat[:heap_final_slots], stat_heap_sum[:heap_final_slots]
assert_equal stat[:heap_eden_pages], stat_heap_sum[:heap_eden_pages]
assert_equal stat[:heap_available_slots], stat_heap_sum[:heap_eden_slots]
assert_equal stat[:total_allocated_objects], stat_heap_sum[:total_allocated_objects]