From 93ac7405b80cc61930d73da04441fa09af1851e1 Mon Sep 17 00:00:00 2001 From: Peter Zhu Date: Tue, 14 Feb 2023 15:55:25 -0500 Subject: Add marking and sweeping time to GC.stat There is a `time` key in GC.stat that gives us the total time spent in GC. However, we don't know what proportion of the time is spent between marking and sweeping. This makes it difficult to tune the GC as we're not sure where to focus our efforts on. This PR adds keys `marking_time` and `sweeping_time` to GC.stat for the time spent marking and sweeping, in milliseconds. [Feature #19437] --- test/ruby/test_gc.rb | 2 ++ 1 file changed, 2 insertions(+) (limited to 'test/ruby') diff --git a/test/ruby/test_gc.rb b/test/ruby/test_gc.rb index 0e3a3b4e1c..4f1d32580a 100644 --- a/test/ruby/test_gc.rb +++ b/test/ruby/test_gc.rb @@ -128,6 +128,8 @@ class TestGc < Test::Unit::TestCase omit 'stress' if GC.stress stat = GC.stat + # marking_time + sweeping_time could differ from time by 1 because they're stored in nanoseconds + assert_in_delta stat[:time], stat[:marking_time] + stat[:sweeping_time], 1 assert_equal stat[:total_allocated_pages], stat[:heap_allocated_pages] + stat[:total_freed_pages] assert_operator stat[:heap_sorted_length], :>=, stat[:heap_eden_pages] + stat[:heap_allocatable_pages], "stat is: " + stat.inspect assert_equal stat[:heap_available_slots], stat[:heap_live_slots] + stat[:heap_free_slots] + stat[:heap_final_slots] -- cgit v1.2.3