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]
This commit is contained in:
Peter Zhu 2023-02-14 15:55:25 -05:00
parent d7c1ca48bf
commit 93ac7405b8
Notes: git 2023-02-21 13:05:51 +00:00
3 changed files with 94 additions and 50 deletions

2
gc.rb
View file

@ -282,7 +282,7 @@ module GC
# Return measured \GC total time in nano seconds.
def self.total_time
Primitive.cexpr! %{
ULL2NUM(rb_objspace.profile.total_time_ns)
ULL2NUM(rb_objspace.profile.marking_time_ns + rb_objspace.profile.sweeping_time_ns)
}
end
end