add debug_counters to check details.

add debug_counters to check the Hash object statistics.
This commit is contained in:
Koichi Sasada 2019-08-02 14:59:29 +09:00
Родитель a0980f2446
Коммит e03b3b4ae0
2 изменённых файлов: 36 добавлений и 12 удалений

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

@ -217,9 +217,14 @@ RB_DEBUG_COUNTER(obj_ary_shared)
RB_DEBUG_COUNTER(obj_ary_shared_root_occupied) RB_DEBUG_COUNTER(obj_ary_shared_root_occupied)
RB_DEBUG_COUNTER(obj_hash_empty) RB_DEBUG_COUNTER(obj_hash_empty)
RB_DEBUG_COUNTER(obj_hash_1_4) RB_DEBUG_COUNTER(obj_hash_1)
RB_DEBUG_COUNTER(obj_hash_2)
RB_DEBUG_COUNTER(obj_hash_3)
RB_DEBUG_COUNTER(obj_hash_4)
RB_DEBUG_COUNTER(obj_hash_5_8) RB_DEBUG_COUNTER(obj_hash_5_8)
RB_DEBUG_COUNTER(obj_hash_g8) RB_DEBUG_COUNTER(obj_hash_g8)
RB_DEBUG_COUNTER(obj_hash_null)
RB_DEBUG_COUNTER(obj_hash_ar) RB_DEBUG_COUNTER(obj_hash_ar)
RB_DEBUG_COUNTER(obj_hash_st) RB_DEBUG_COUNTER(obj_hash_st)
RB_DEBUG_COUNTER(obj_hash_transient) RB_DEBUG_COUNTER(obj_hash_transient)

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

@ -2448,21 +2448,40 @@ obj_free(rb_objspace_t *objspace, VALUE obj)
break; break;
case T_HASH: case T_HASH:
#if USE_DEBUG_COUNTER #if USE_DEBUG_COUNTER
if (RHASH_SIZE(obj) > 8) { switch RHASH_SIZE(obj) {
RB_DEBUG_COUNTER_INC(obj_hash_g8); case 0:
}
else if (RHASH_SIZE(obj) > 4) {
RB_DEBUG_COUNTER_INC(obj_hash_5_8);
}
else if (RHASH_SIZE(obj) > 0) {
RB_DEBUG_COUNTER_INC(obj_hash_1_4);
}
else {
RB_DEBUG_COUNTER_INC(obj_hash_empty); RB_DEBUG_COUNTER_INC(obj_hash_empty);
break;
case 1:
RB_DEBUG_COUNTER_INC(obj_hash_1);
break;
case 2:
RB_DEBUG_COUNTER_INC(obj_hash_2);
break;
case 3:
RB_DEBUG_COUNTER_INC(obj_hash_3);
break;
case 4:
RB_DEBUG_COUNTER_INC(obj_hash_4);
break;
case 5:
case 6:
case 7:
case 8:
RB_DEBUG_COUNTER_INC(obj_hash_5_8);
break;
default:
GC_ASSERT(RHASH_SIZE(obj) > 8);
RB_DEBUG_COUNTER_INC(obj_hash_g8);
} }
if (RHASH_AR_TABLE_P(obj)) { if (RHASH_AR_TABLE_P(obj)) {
RB_DEBUG_COUNTER_INC(obj_hash_ar); if (RHASH_AR_TABLE(obj) == NULL) {
RB_DEBUG_COUNTER_INC(obj_hash_null);
}
else {
RB_DEBUG_COUNTER_INC(obj_hash_ar);
}
} }
else { else {
RB_DEBUG_COUNTER_INC(obj_hash_st); RB_DEBUG_COUNTER_INC(obj_hash_st);