diff options
author | Aaron Patterson <tenderlove@ruby-lang.org> | 2019-11-07 12:46:14 -0800 |
---|---|---|
committer | Aaron Patterson <tenderlove@ruby-lang.org> | 2019-11-07 12:46:14 -0800 |
commit | dddf5afb7947f5aba1ff875e9f5eb163f8c3d6c7 (patch) | |
tree | 54dad3b61f118d19b4ece146c1ff2d13d4ffd75b | |
parent | 597ec4354333573d69f57dad931cb8ef477d191a (diff) | |
download | ruby-dddf5afb7947f5aba1ff875e9f5eb163f8c3d6c7.tar.gz |
Add a counter for compaction
Keep track of the number of times the compactor ran. I would like to
use this as a way to keep track of inline cache reference updates.
-rw-r--r-- | gc.c | 6 | ||||
-rw-r--r-- | test/ruby/test_gc_compact.rb | 6 |
2 files changed, 12 insertions, 0 deletions
@@ -748,6 +748,7 @@ typedef struct rb_objspace { #if USE_RGENGC size_t minor_gc_count; size_t major_gc_count; + size_t compact_count; #if RGENGC_PROFILE > 0 size_t total_generated_normal_object_count; size_t total_generated_shady_object_count; @@ -8549,6 +8550,8 @@ gc_compact_after_gc(rb_objspace_t *objspace, int use_toward_empty, int use_doubl mjit_gc_start_hook(); // prevent MJIT from running while moving pointers related to ISeq + objspace->profile.compact_count++; + if (use_verifier) { gc_verify_internal_consistency(objspace); } @@ -8890,6 +8893,7 @@ enum gc_stat_sym { #if USE_RGENGC gc_stat_sym_minor_gc_count, gc_stat_sym_major_gc_count, + gc_stat_sym_compact_count, gc_stat_sym_remembered_wb_unprotected_objects, gc_stat_sym_remembered_wb_unprotected_objects_limit, gc_stat_sym_old_objects, @@ -8966,6 +8970,7 @@ setup_gc_stat_symbols(void) #if USE_RGENGC S(minor_gc_count); S(major_gc_count); + S(compact_count); S(remembered_wb_unprotected_objects); S(remembered_wb_unprotected_objects_limit); S(old_objects); @@ -9138,6 +9143,7 @@ gc_stat_internal(VALUE hash_or_sym) #if USE_RGENGC SET(minor_gc_count, objspace->profile.minor_gc_count); SET(major_gc_count, objspace->profile.major_gc_count); + SET(compact_count, objspace->profile.compact_count); SET(remembered_wb_unprotected_objects, objspace->rgengc.uncollectible_wb_unprotected_objects); SET(remembered_wb_unprotected_objects_limit, objspace->rgengc.uncollectible_wb_unprotected_objects_limit); SET(old_objects, objspace->rgengc.old_objects); diff --git a/test/ruby/test_gc_compact.rb b/test/ruby/test_gc_compact.rb index bc26897386..e93e775279 100644 --- a/test/ruby/test_gc_compact.rb +++ b/test/ruby/test_gc_compact.rb @@ -54,4 +54,10 @@ class TestGCCompact < Test::Unit::TestCase assert GC.compact walk_ast ast end + + def test_compact_count + count = GC.stat(:compact_count) + GC.compact + assert_equal count + 1, GC.stat(:compact_count) + end end |