Recently I added some debug counters to MRI and I want to share results.
(See comments 
https://github.com/ruby/ruby/blob/trunk/debug_counter.h#L18 for details)

# summary

* optcarrot kicks many Ruby methods (80%) but rdoc (25%) and discourse 
(45%) do not kick. instead of Ruby method, cfuncs are used (optcarrot: 
10%, rdoc:70%, discourse:40%).

* inline cache hit ratio is nice.

* promotion ratio (gengc) is under 10%. seems good.

* many imemo_svar on discourse, but compared with pushed frame, it seems 
reasonable.

[RUBY_DEBUG_COUNTER]    frame_push_method                456,075,698
[RUBY_DEBUG_COUNTER]    obj_imemo_svar                     9,781,946

* (discourse bench) most of T_HASH objects are small.

[RUBY_DEBUG_COUNTER]    obj_hash_empty                     3,632,018
[RUBY_DEBUG_COUNTER]    obj_hash_under4                    4,204,927
[RUBY_DEBUG_COUNTER]    obj_hash_ge4                       2,453,149
[RUBY_DEBUG_COUNTER]    obj_hash_ge8                         841,866

* (discourse bench) many class objects are collected. `Class.new` are 
used frequently?

[RUBY_DEBUG_COUNTER]    obj_iclass_ptr                             3
[RUBY_DEBUG_COUNTER]    obj_class_ptr                        214,180
[RUBY_DEBUG_COUNTER]    obj_module_ptr                             2


optcarrot:
./miniruby ~/src/ruby/trunk/benchmark/optcarrot/bin/optcarrot 
--benchmark ~/src/ruby/trunk/benchmark/optcarrot/examples/Lan_Master.nes

[RUBY_DEBUG_COUNTER]    mc_inline_hit                       89,376,363
[RUBY_DEBUG_COUNTER]    mc_inline_miss                         103,503
[RUBY_DEBUG_COUNTER]    mc_global_hit                        4,648,921
[RUBY_DEBUG_COUNTER]    mc_global_miss                             847
[RUBY_DEBUG_COUNTER]    mc_global_state_miss                    96,652
[RUBY_DEBUG_COUNTER]    mc_class_serial_miss                     6,851
[RUBY_DEBUG_COUNTER]    mc_cme_complement                      336,007
[RUBY_DEBUG_COUNTER]    mc_cme_complement_hit                  335,990
[RUBY_DEBUG_COUNTER]    mc_search_super                          2,531
[RUBY_DEBUG_COUNTER]    frame_push                          90,678,148
[RUBY_DEBUG_COUNTER]    frame_push_method                   72,348,300
[RUBY_DEBUG_COUNTER]    frame_push_block                     4,290,050
[RUBY_DEBUG_COUNTER]    frame_push_class                            46
[RUBY_DEBUG_COUNTER]    frame_push_top                              15
[RUBY_DEBUG_COUNTER]    frame_push_cfunc                    11,765,806
[RUBY_DEBUG_COUNTER]    frame_push_ifunc                     2,273,928
[RUBY_DEBUG_COUNTER]    frame_push_eval                              1
[RUBY_DEBUG_COUNTER]    frame_push_rescue                            0
[RUBY_DEBUG_COUNTER]    frame_push_dummy                             2
[RUBY_DEBUG_COUNTER]    ivar_get_ic_hit                    295,914,323
[RUBY_DEBUG_COUNTER]    ivar_get_ic_miss                             0
[RUBY_DEBUG_COUNTER]    ivar_get_ic_miss_serial                  8,970
[RUBY_DEBUG_COUNTER]    ivar_get_ic_miss_unset                      37
[RUBY_DEBUG_COUNTER]    ivar_get_ic_miss_noobject                    0
[RUBY_DEBUG_COUNTER]    ivar_set_ic_hit                     60,775,437
[RUBY_DEBUG_COUNTER]    ivar_set_ic_miss                         2,403
[RUBY_DEBUG_COUNTER]    ivar_set_ic_miss_serial                  2,399
[RUBY_DEBUG_COUNTER]    ivar_set_ic_miss_unset                       2
[RUBY_DEBUG_COUNTER]    ivar_set_ic_miss_oorange                     2
[RUBY_DEBUG_COUNTER]    ivar_set_ic_miss_noobject                    0
[RUBY_DEBUG_COUNTER]    ivar_get_base                              500
[RUBY_DEBUG_COUNTER]    ivar_set_base                            2,974
[RUBY_DEBUG_COUNTER]    lvar_get                            50,758,088
[RUBY_DEBUG_COUNTER]    lvar_get_dynamic                     6,395,062
[RUBY_DEBUG_COUNTER]    lvar_set                            17,990,783
[RUBY_DEBUG_COUNTER]    lvar_set_dynamic                             0
[RUBY_DEBUG_COUNTER]    lvar_set_slowpath                            0
[RUBY_DEBUG_COUNTER]    obj_newobj                             390,384
[RUBY_DEBUG_COUNTER]    obj_newobj_slowpath                      1,023
[RUBY_DEBUG_COUNTER]    obj_newobj_wb_unprotected                  170
[RUBY_DEBUG_COUNTER]    obj_free                                14,408
[RUBY_DEBUG_COUNTER]    obj_promote                            270,020
[RUBY_DEBUG_COUNTER]    obj_wb_unprotect                            41
[RUBY_DEBUG_COUNTER]    obj_obj_ptr                                  0
[RUBY_DEBUG_COUNTER]    obj_obj_embed                                1
[RUBY_DEBUG_COUNTER]    obj_str_ptr                              2,610
[RUBY_DEBUG_COUNTER]    obj_str_embed                            7,100
[RUBY_DEBUG_COUNTER]    obj_str_shared                             295
[RUBY_DEBUG_COUNTER]    obj_str_nofree                               0
[RUBY_DEBUG_COUNTER]    obj_str_fstr                                85
[RUBY_DEBUG_COUNTER]    obj_ary_ptr                                635
[RUBY_DEBUG_COUNTER]    obj_ary_embed                            2,139
[RUBY_DEBUG_COUNTER]    obj_hash_empty                               8
[RUBY_DEBUG_COUNTER]    obj_hash_under4                             20
[RUBY_DEBUG_COUNTER]    obj_hash_ge4                                19
[RUBY_DEBUG_COUNTER]    obj_hash_ge8                                18
[RUBY_DEBUG_COUNTER]    obj_struct_ptr                               0
[RUBY_DEBUG_COUNTER]    obj_struct_embed                             5
[RUBY_DEBUG_COUNTER]    obj_regexp_ptr                               0
[RUBY_DEBUG_COUNTER]    obj_data_empty                               0
[RUBY_DEBUG_COUNTER]    obj_data_xfree                               0
[RUBY_DEBUG_COUNTER]    obj_data_imm_free                           31
[RUBY_DEBUG_COUNTER]    obj_data_zombie                              0
[RUBY_DEBUG_COUNTER]    obj_match_ptr                                0
[RUBY_DEBUG_COUNTER]    obj_file_ptr                                16
[RUBY_DEBUG_COUNTER]    obj_bignum_ptr                               0
[RUBY_DEBUG_COUNTER]    obj_symbol                                   0
[RUBY_DEBUG_COUNTER]    obj_imemo_ment                               1
[RUBY_DEBUG_COUNTER]    obj_imemo_iseq                              66
[RUBY_DEBUG_COUNTER]    obj_imemo_env                                0
[RUBY_DEBUG_COUNTER]    obj_imemo_tmpbuf                         1,051
[RUBY_DEBUG_COUNTER]    obj_imemo_ast                               14
[RUBY_DEBUG_COUNTER]    obj_imemo_cref                               3
[RUBY_DEBUG_COUNTER]    obj_imemo_svar                               9
[RUBY_DEBUG_COUNTER]    obj_imemo_throw_data                         8
[RUBY_DEBUG_COUNTER]    obj_imemo_ifunc                             54
[RUBY_DEBUG_COUNTER]    obj_imemo_memo                               0
[RUBY_DEBUG_COUNTER]    obj_imemo_parser_strterm                   324
[RUBY_DEBUG_COUNTER]    obj_iclass_ptr                               0
[RUBY_DEBUG_COUNTER]    obj_class_ptr                                0
[RUBY_DEBUG_COUNTER]    obj_module_ptr                               0
[RUBY_DEBUG_COUNTER]    heap_xmalloc                           283,633
[RUBY_DEBUG_COUNTER]    heap_xrealloc                           10,668
[RUBY_DEBUG_COUNTER]    heap_xfree                              14,273

rdoc bench:
[RUBY_DEBUG_COUNTER]    mc_inline_hit                     77,428,972
[RUBY_DEBUG_COUNTER]    mc_inline_miss                       398,444
[RUBY_DEBUG_COUNTER]    mc_global_hit                     43,118,649
[RUBY_DEBUG_COUNTER]    mc_global_miss                       206,863
[RUBY_DEBUG_COUNTER]    mc_global_state_miss                 172,252
[RUBY_DEBUG_COUNTER]    mc_class_serial_miss                 226,192
[RUBY_DEBUG_COUNTER]    mc_cme_complement                    578,430
[RUBY_DEBUG_COUNTER]    mc_cme_complement_hit                578,258
[RUBY_DEBUG_COUNTER]    mc_search_super                      419,234
[RUBY_DEBUG_COUNTER]    frame_push                       106,726,743
[RUBY_DEBUG_COUNTER]    frame_push_method                 24,748,780
[RUBY_DEBUG_COUNTER]    frame_push_block                   7,822,562
[RUBY_DEBUG_COUNTER]    frame_push_class                         302
[RUBY_DEBUG_COUNTER]    frame_push_top                           144
[RUBY_DEBUG_COUNTER]    frame_push_cfunc                  70,773,376
[RUBY_DEBUG_COUNTER]    frame_push_ifunc                   3,364,914
[RUBY_DEBUG_COUNTER]    frame_push_eval                          311
[RUBY_DEBUG_COUNTER]    frame_push_rescue                     15,737
[RUBY_DEBUG_COUNTER]    frame_push_dummy                         617
[RUBY_DEBUG_COUNTER]    ivar_get_ic_hit                   44,761,598
[RUBY_DEBUG_COUNTER]    ivar_get_ic_miss                   1,047,831
[RUBY_DEBUG_COUNTER]    ivar_get_ic_miss_serial              172,338
[RUBY_DEBUG_COUNTER]    ivar_get_ic_miss_unset                11,629
[RUBY_DEBUG_COUNTER]    ivar_get_ic_miss_noobject          1,047,831
[RUBY_DEBUG_COUNTER]    ivar_set_ic_hit                   12,562,323
[RUBY_DEBUG_COUNTER]    ivar_set_ic_miss                   1,766,706
[RUBY_DEBUG_COUNTER]    ivar_set_ic_miss_serial              909,112
[RUBY_DEBUG_COUNTER]    ivar_set_ic_miss_unset                15,224
[RUBY_DEBUG_COUNTER]    ivar_set_ic_miss_oorange             840,623
[RUBY_DEBUG_COUNTER]    ivar_set_ic_miss_noobject              1,747
[RUBY_DEBUG_COUNTER]    ivar_get_base                      1,055,294
[RUBY_DEBUG_COUNTER]    ivar_set_base                      1,849,312
[RUBY_DEBUG_COUNTER]    lvar_get                          79,359,909
[RUBY_DEBUG_COUNTER]    lvar_get_dynamic                   5,580,637
[RUBY_DEBUG_COUNTER]    lvar_set                          21,715,967
[RUBY_DEBUG_COUNTER]    lvar_set_dynamic                   1,267,319
[RUBY_DEBUG_COUNTER]    lvar_set_slowpath                        874
[RUBY_DEBUG_COUNTER]    obj_newobj                        29,299,839
[RUBY_DEBUG_COUNTER]    obj_newobj_slowpath                  192,547
[RUBY_DEBUG_COUNTER]    obj_newobj_wb_unprotected            590,949
[RUBY_DEBUG_COUNTER]    obj_free                          27,251,061
[RUBY_DEBUG_COUNTER]    obj_promote                        2,447,736
[RUBY_DEBUG_COUNTER]    obj_wb_unprotect                       1,159
[RUBY_DEBUG_COUNTER]    obj_obj_ptr                          605,511
[RUBY_DEBUG_COUNTER]    obj_obj_embed                          9,822
[RUBY_DEBUG_COUNTER]    obj_str_ptr                        1,870,485
[RUBY_DEBUG_COUNTER]    obj_str_embed                      8,329,469
[RUBY_DEBUG_COUNTER]    obj_str_shared                       929,035
[RUBY_DEBUG_COUNTER]    obj_str_nofree                             0
[RUBY_DEBUG_COUNTER]    obj_str_fstr                          14,149
[RUBY_DEBUG_COUNTER]    obj_ary_ptr                        2,922,263
[RUBY_DEBUG_COUNTER]    obj_ary_embed                      7,833,680
[RUBY_DEBUG_COUNTER]    obj_hash_empty                         5,875
[RUBY_DEBUG_COUNTER]    obj_hash_under4                      897,624
[RUBY_DEBUG_COUNTER]    obj_hash_ge4                           6,727
[RUBY_DEBUG_COUNTER]    obj_hash_ge8                           3,541
[RUBY_DEBUG_COUNTER]    obj_struct_ptr                     1,609,329
[RUBY_DEBUG_COUNTER]    obj_struct_embed                     819,380
[RUBY_DEBUG_COUNTER]    obj_regexp_ptr                        42,421
[RUBY_DEBUG_COUNTER]    obj_tdata_empty                            1
[RUBY_DEBUG_COUNTER]    obj_tdata_xfree                       14,864
[RUBY_DEBUG_COUNTER]    obj_tdata_imm_free                    54,654
[RUBY_DEBUG_COUNTER]    obj_tdata_zombie                           0
[RUBY_DEBUG_COUNTER]    obj_match_ptr                        493,960
[RUBY_DEBUG_COUNTER]    obj_file_ptr                          19,443
[RUBY_DEBUG_COUNTER]    obj_bignum_ptr                             0
[RUBY_DEBUG_COUNTER]    obj_symbol                               172
[RUBY_DEBUG_COUNTER]    obj_imemo_ment                           534
[RUBY_DEBUG_COUNTER]    obj_imemo_iseq                           831
[RUBY_DEBUG_COUNTER]    obj_imemo_env                          7,558
[RUBY_DEBUG_COUNTER]    obj_imemo_tmpbuf                       8,087
[RUBY_DEBUG_COUNTER]    obj_imemo_ast                          1,060
[RUBY_DEBUG_COUNTER]    obj_imemo_cref                           117
[RUBY_DEBUG_COUNTER]    obj_imemo_svar                       606,690
[RUBY_DEBUG_COUNTER]    obj_imemo_throw_data                  57,918
[RUBY_DEBUG_COUNTER]    obj_imemo_ifunc                       37,417
[RUBY_DEBUG_COUNTER]    obj_imemo_memo                        24,137
[RUBY_DEBUG_COUNTER]    obj_imemo_parser_strterm              42,593
[RUBY_DEBUG_COUNTER]    obj_iclass_ptr                           196
[RUBY_DEBUG_COUNTER]    obj_class_ptr                            196
[RUBY_DEBUG_COUNTER]    obj_module_ptr                             1
[RUBY_DEBUG_COUNTER]    heap_xmalloc                      13,010,847
[RUBY_DEBUG_COUNTER]    heap_xrealloc                        617,023
[RUBY_DEBUG_COUNTER]    heap_xfree                        12,830,149

discourse benchmark:
[RUBY_DEBUG_COUNTER]    mc_inline_hit                    827,105,628
[RUBY_DEBUG_COUNTER]    mc_inline_miss                    85,478,373
[RUBY_DEBUG_COUNTER]    mc_global_hit                    421,599,808
[RUBY_DEBUG_COUNTER]    mc_global_miss                    23,896,575
[RUBY_DEBUG_COUNTER]    mc_global_state_miss               7,819,069
[RUBY_DEBUG_COUNTER]    mc_class_serial_miss              77,659,304
[RUBY_DEBUG_COUNTER]    mc_cme_complement                 62,369,652
[RUBY_DEBUG_COUNTER]    mc_cme_complement_hit             62,365,310
[RUBY_DEBUG_COUNTER]    mc_search_super                  270,286,253
[RUBY_DEBUG_COUNTER]    frame_push                     1,011,877,345
[RUBY_DEBUG_COUNTER]    frame_push_method                456,075,698
[RUBY_DEBUG_COUNTER]    frame_push_block                  79,600,045
[RUBY_DEBUG_COUNTER]    frame_push_class                       8,230
[RUBY_DEBUG_COUNTER]    frame_push_top                         3,360
[RUBY_DEBUG_COUNTER]    frame_push_cfunc                 460,186,970
[RUBY_DEBUG_COUNTER]    frame_push_ifunc                  15,987,591
[RUBY_DEBUG_COUNTER]    frame_push_eval                        8,956
[RUBY_DEBUG_COUNTER]    frame_push_rescue                      6,452
[RUBY_DEBUG_COUNTER]    frame_push_dummy                          43
[RUBY_DEBUG_COUNTER]    ivar_get_ic_hit                  266,182,208
[RUBY_DEBUG_COUNTER]    ivar_get_ic_miss                  39,870,538
[RUBY_DEBUG_COUNTER]    ivar_get_ic_miss_serial           14,812,107
[RUBY_DEBUG_COUNTER]    ivar_get_ic_miss_unset            70,754,630
[RUBY_DEBUG_COUNTER]    ivar_get_ic_miss_noobject         39,870,538
[RUBY_DEBUG_COUNTER]    ivar_set_ic_hit                   34,252,656
[RUBY_DEBUG_COUNTER]    ivar_set_ic_miss                  32,815,298
[RUBY_DEBUG_COUNTER]    ivar_set_ic_miss_serial           20,363,431
[RUBY_DEBUG_COUNTER]    ivar_set_ic_miss_unset                59,976
[RUBY_DEBUG_COUNTER]    ivar_set_ic_miss_oorange          11,232,104
[RUBY_DEBUG_COUNTER]    ivar_set_ic_miss_noobject          1,159,787
[RUBY_DEBUG_COUNTER]    ivar_get_base                     32,408,710
[RUBY_DEBUG_COUNTER]    ivar_set_base                     32,982,910
[RUBY_DEBUG_COUNTER]    lvar_get                         850,406,822
[RUBY_DEBUG_COUNTER]    lvar_get_dynamic                  78,720,786
[RUBY_DEBUG_COUNTER]    lvar_set                         165,103,921
[RUBY_DEBUG_COUNTER]    lvar_set_dynamic                   1,396,046
[RUBY_DEBUG_COUNTER]    lvar_set_slowpath                    299,163
[RUBY_DEBUG_COUNTER]    obj_newobj                       162,910,687
[RUBY_DEBUG_COUNTER]    obj_newobj_slowpath                1,156,993
[RUBY_DEBUG_COUNTER]    obj_newobj_wb_unprotected          2,108,078
[RUBY_DEBUG_COUNTER]    obj_free                         161,117,628
[RUBY_DEBUG_COUNTER]    obj_promote                        7,289,299
[RUBY_DEBUG_COUNTER]    obj_wb_unprotect                      83,599
[RUBY_DEBUG_COUNTER]    obj_obj_ptr                        8,505,888
[RUBY_DEBUG_COUNTER]    obj_obj_embed                      4,395,142
[RUBY_DEBUG_COUNTER]    obj_str_ptr                        6,345,111
[RUBY_DEBUG_COUNTER]    obj_str_embed                     63,065,862
[RUBY_DEBUG_COUNTER]    obj_str_shared                     7,865,747
[RUBY_DEBUG_COUNTER]    obj_str_nofree                             0
[RUBY_DEBUG_COUNTER]    obj_str_fstr                          15,844
[RUBY_DEBUG_COUNTER]    obj_ary_ptr                        5,016,497
[RUBY_DEBUG_COUNTER]    obj_ary_embed                     35,748,852
[RUBY_DEBUG_COUNTER]    obj_hash_empty                     3,632,018
[RUBY_DEBUG_COUNTER]    obj_hash_under4                    4,204,927
[RUBY_DEBUG_COUNTER]    obj_hash_ge4                       2,453,149
[RUBY_DEBUG_COUNTER]    obj_hash_ge8                         841,866
[RUBY_DEBUG_COUNTER]    obj_struct_ptr                            99
[RUBY_DEBUG_COUNTER]    obj_struct_embed                   1,640,606
[RUBY_DEBUG_COUNTER]    obj_regexp_ptr                        13,727
[RUBY_DEBUG_COUNTER]    obj_tdata_empty                       16,913
[RUBY_DEBUG_COUNTER]    obj_tdata_xfree                    1,696,390
[RUBY_DEBUG_COUNTER]    obj_tdata_imm_free                   153,666
[RUBY_DEBUG_COUNTER]    obj_tdata_zombie                      90,055
[RUBY_DEBUG_COUNTER]    obj_match_ptr                        945,865
[RUBY_DEBUG_COUNTER]    obj_file_ptr                           6,702
[RUBY_DEBUG_COUNTER]    obj_bignum_ptr                             0
[RUBY_DEBUG_COUNTER]    obj_symbol                               360
[RUBY_DEBUG_COUNTER]    obj_imemo_ment                        11,830
[RUBY_DEBUG_COUNTER]    obj_imemo_iseq                        20,497
[RUBY_DEBUG_COUNTER]    obj_imemo_env                        544,268
[RUBY_DEBUG_COUNTER]    obj_imemo_tmpbuf                     114,703
[RUBY_DEBUG_COUNTER]    obj_imemo_ast                         12,375
[RUBY_DEBUG_COUNTER]    obj_imemo_cref                        46,785
[RUBY_DEBUG_COUNTER]    obj_imemo_svar                     9,781,946
[RUBY_DEBUG_COUNTER]    obj_imemo_throw_data                 322,125
[RUBY_DEBUG_COUNTER]    obj_imemo_ifunc                    2,525,995
[RUBY_DEBUG_COUNTER]    obj_imemo_memo                     1,176,900
[RUBY_DEBUG_COUNTER]    obj_imemo_parser_strterm              56,035
[RUBY_DEBUG_COUNTER]    obj_iclass_ptr                             3
[RUBY_DEBUG_COUNTER]    obj_class_ptr                        214,180
[RUBY_DEBUG_COUNTER]    obj_module_ptr                             2
[RUBY_DEBUG_COUNTER]    heap_xmalloc                      65,450,288
[RUBY_DEBUG_COUNTER]    heap_xrealloc                      5,007,429
[RUBY_DEBUG_COUNTER]    heap_xfree                        67,890,531



-- 
// SASADA Koichi at atdot dot net

Unsubscribe: <mailto:ruby-core-request / ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>