fix debug counter for Hash counts.

Change debug_counters for Hash object counts:

* obj_hash_under4 (1-3) -> obj_hash_1_4 (1-4)
* obj_hash_ge4 (4-7)    -> obj_hash_5_8 (5-8)
* obj_hash_ge8 (>=8)    -> obj_hash_g8  (> 8)

For example on rdoc benchmark:

[RUBY_DEBUG_COUNTER]    obj_hash_empty                         554,900
[RUBY_DEBUG_COUNTER]    obj_hash_under4                        572,998
[RUBY_DEBUG_COUNTER]    obj_hash_ge4                             1,825
[RUBY_DEBUG_COUNTER]    obj_hash_ge8                             2,344
[RUBY_DEBUG_COUNTER]    obj_hash_empty                         553,097
[RUBY_DEBUG_COUNTER]    obj_hash_1_4                           571,880
[RUBY_DEBUG_COUNTER]    obj_hash_5_8                               982
[RUBY_DEBUG_COUNTER]    obj_hash_g8                              2,189
This commit is contained in:
Koichi Sasada 2019-07-19 16:24:14 +09:00
Родитель ae750799c1
Коммит fba3e76e3f
2 изменённых файлов: 12 добавлений и 12 удалений

Просмотреть файл

@ -174,9 +174,9 @@ RB_DEBUG_COUNTER(gc_isptr_maybe)
* * str_nofree: nofree
* * str_fstr: fstr
* * hash_empty: hash is empty
* * hash_under4: has under 4 entries
* * hash_ge4: has n entries (4<=n<8)
* * hash_ge8: has n entries (8<=n)
* * hash_1_4: has 1 to 4 entries
* * hash_5_8: has 5 to 8 entries
* * hash_g8: has n entries (n>8)
* * match_under4: has under 4 oniguruma regions allocated
* * match_ge4: has n regions allocated (4<=n<8)
* * match_ge8: has n regions allocated (8<=n)
@ -217,9 +217,9 @@ RB_DEBUG_COUNTER(obj_ary_shared)
RB_DEBUG_COUNTER(obj_ary_shared_root_occupied)
RB_DEBUG_COUNTER(obj_hash_empty)
RB_DEBUG_COUNTER(obj_hash_under4)
RB_DEBUG_COUNTER(obj_hash_ge4)
RB_DEBUG_COUNTER(obj_hash_ge8)
RB_DEBUG_COUNTER(obj_hash_1_4)
RB_DEBUG_COUNTER(obj_hash_5_8)
RB_DEBUG_COUNTER(obj_hash_g8)
RB_DEBUG_COUNTER(obj_hash_ar)
RB_DEBUG_COUNTER(obj_hash_st)
RB_DEBUG_COUNTER(obj_hash_transient)

12
gc.c
Просмотреть файл

@ -2410,14 +2410,14 @@ obj_free(rb_objspace_t *objspace, VALUE obj)
break;
case T_HASH:
#if USE_DEBUG_COUNTER
if (RHASH_SIZE(obj) >= 8) {
RB_DEBUG_COUNTER_INC(obj_hash_ge8);
if (RHASH_SIZE(obj) > 8) {
RB_DEBUG_COUNTER_INC(obj_hash_g8);
}
else if (RHASH_SIZE(obj) >= 4) {
RB_DEBUG_COUNTER_INC(obj_hash_ge4);
else if (RHASH_SIZE(obj) > 4) {
RB_DEBUG_COUNTER_INC(obj_hash_5_8);
}
else if (RHASH_SIZE(obj) >= 1) {
RB_DEBUG_COUNTER_INC(obj_hash_under4);
else if (RHASH_SIZE(obj) > 0) {
RB_DEBUG_COUNTER_INC(obj_hash_1_4);
}
else {
RB_DEBUG_COUNTER_INC(obj_hash_empty);