Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

YJIT: Use general definedivar at the end of chains #7756

Merged
merged 1 commit into from Apr 24, 2023

Conversation

k0kubun
Copy link
Member

@k0kubun k0kubun commented Apr 24, 2023

Running #7755 locally with a bare SFR stats hash, I confirmed definedivar exit reasons consist of:

definedivar exit reasons:
    megamorphic: 27,640,363 (100.0%)

which makes up 4.3% overall.

Similar to what we do for getivar and setivar, I think we should use a general case at the last chain to avoid side exits.

@matzbot matzbot requested a review from a team April 24, 2023 17:46
@k0kubun k0kubun merged commit f492e3b into ruby:master Apr 24, 2023
97 of 98 checks passed
@k0kubun k0kubun deleted the yjit-general-defivar branch April 24, 2023 19:20
@k0kubun
Copy link
Member Author

k0kubun commented Apr 25, 2023

definedivar exits are gone from SFR.

before

***YJIT: Printing YJIT statistics on exit***
method call exit reasons: 
                           kw_splat: 138,512,397 (24.8%)
                    iseq_has_kwrest: 87,926,421 (15.7%)
                iseq_ruby2_keywords: 86,721,978 (15.5%)
                  klass_megamorphic: 47,312,117 ( 8.5%)
                     iseq_has_no_kw: 37,672,650 ( 6.7%)
                    args_splat_ivar: 31,393,187 ( 5.6%)
          args_splat_cfunc_var_args: 26,013,784 ( 4.7%)
                      zsuper_method: 16,043,009 ( 2.9%)
                          block_arg: 15,188,953 ( 2.7%)
                        not_fixnums: 15,086,768 ( 2.7%)
                   iseq_arity_error: 14,897,090 ( 2.7%)
                args_splat_opt_call:  9,592,944 ( 1.7%)
                           keywords:  9,068,512 ( 1.6%)
                        send_getter:  7,017,789 ( 1.3%)
                        iseq_zsuper:  4,145,652 ( 0.7%)
                         send_chain:  3,833,858 ( 0.7%)
                       mid_mismatch:  2,424,494 ( 0.4%)
                    ivar_set_method:  1,785,988 ( 0.3%)
           iseq_missing_optional_kw:    615,573 ( 0.1%)
    args_splat_cfunc_ruby2_keywords:    488,318 ( 0.1%)
         instance_of_class_mismatch:    420,809 ( 0.1%)
              send_chain_not_string:    407,641 ( 0.1%)
                 iseq_splat_with_kw:    364,148 ( 0.1%)
            iseq_materialized_block:    228,930 ( 0.0%)
              cfunc_ruby_array_varg:    208,540 ( 0.0%)
                is_a_class_mismatch:    204,008 ( 0.0%)
        iseq_has_rest_opt_and_block:    196,447 ( 0.0%)
             iseq_has_rest_and_send:    160,641 ( 0.0%)
        optimized_method_block_call:    146,535 ( 0.0%)
             args_splat_cfunc_zuper:    116,185 ( 0.0%)
                        interrupted:    111,641 ( 0.0%)
                     refined_method:     59,025 ( 0.0%)
                         call_kwarg:      1,580 ( 0.0%)
                 cfunc_toomany_args:        239 ( 0.0%)
        splatarray_length_not_equal:         33 ( 0.0%)
             iseq_splat_arity_error:         12 ( 0.0%)
invokeblock exit reasons: 
                  proc:  2,962,922 (57.8%)
    iseq_block_changed:  1,544,216 (30.2%)
                symbol:    614,624 (12.0%)
invokesuper exit reasons: 
         block:  3,836,620 (54.8%)
    me_changed:  3,166,781 (45.2%)
leave exit reasons: 
    interp_return: 3,519,061,934 (100.0%)
     se_interrupt:     91,507 ( 0.0%)
getblockparamproxy exit reasons: 
    block_param_modified:    149,526 (100.0%)
getinstancevariable exit reasons:
    megamorphic:      2,217 (100.0%)
setinstancevariable exit reasons:
    (all relevant counters are zero)
opt_aref exit reasons: 
    not_hash:    270,298 (100.0%)
expandarray exit reasons: 
    rhs_too_small:  8,025,061 (97.9%)
            splat:    131,383 ( 1.6%)
        not_array:     43,762 ( 0.5%)
opt_getinlinecache exit reasons: 
    miss:        101 (100.0%)
invalidation reasons: 
          method_lookup:      1,762 (47.3%)
    constant_state_bump:      1,037 (27.8%)
       constant_ic_fill:        929 (24.9%)
num_send:              28,495,181,529
num_send_known_class:  2,022,941,852 ( 7.1%)
num_send_polymorphic:  7,444,498,730 (26.1%)
num_send_x86_rel32:          173,603
num_send_x86_reg:              1,221
iseq_stack_too_large:              0
iseq_too_long:                     0
temp_reg_opnd:               962,911
temp_mem_opnd:               705,647
temp_spill:                  616,158
bindings_allocations:         28,025
bindings_set:                  8,210
compiled_iseq_count:          12,176
compiled_blockid_count:      117,805
compiled_block_count:        193,239
versions_per_block:            1.640
compiled_branch_count:       372,116
block_next_count:            179,550
defer_count:                  54,051
defer_empty_count:            14,584
branch_insn_count:            15,035
branch_known_count:            3,460 (23.0%)
freed_iseq_count:                  2
invalidation_count:            3,728
constant_state_bumps:              0
get_ivar_max_depth:      282,052,080
inline_code_size:         20,471,779
outlined_code_size:       18,199,192
code_region_size:         39,731,200
freed_code_size:                   0
yjit_alloc_size:          82,951,025
live_context_size:         9,459,046
live_context_count:          326,174
live_page_count:               2,425
freed_page_count:                  0
code_gc_count:                     0
num_gc_obj_refs:             167,652
object_shape_count:           12,808
side_exit_count:         620,909,705
total_exit_count:      4,139,971,639
total_insns_count:     162,001,101,279
vm_insns_count:        10,891,620,583
yjit_insns_count:      151,730,390,401
ratio_in_yjit:                 93.3%
avg_len_in_yjit:                36.5
Top-20 most frequent exit ops (100.0% of exits):
    opt_send_without_block: 349,422,703 (56.3%)
                      send: 149,153,481 (24.0%)
               invokesuper: 39,778,122 ( 6.4%)
               definedivar: 24,080,770 ( 3.9%)
               invokeblock: 20,018,852 ( 3.2%)
                    opt_eq: 14,506,897 ( 2.3%)
               expandarray:  8,200,206 ( 1.3%)
       setinstancevariable:  7,152,400 ( 1.2%)
                checkmatch:  2,683,982 ( 0.4%)
             setlocal_WC_0:  1,501,025 ( 0.2%)
        getblockparamproxy:  1,407,182 ( 0.2%)
      opt_getconstant_path:  1,216,310 ( 0.2%)
                  opt_aref:    595,269 ( 0.1%)
             opt_aref_with:    423,661 ( 0.1%)
                   opt_not:    157,774 ( 0.0%)
                      once:    141,807 ( 0.0%)
             opt_aset_with:    138,409 ( 0.0%)
             setblockparam:     91,751 ( 0.0%)
                     leave:     91,507 ( 0.0%)
           newarraykwsplat:     52,364 ( 0.0%)

after

***YJIT: Printing YJIT statistics on exit***
method call exit reasons: 
                           kw_splat: 138,538,119 (25.5%)
                    iseq_has_kwrest: 86,612,208 (15.9%)
                iseq_ruby2_keywords: 82,446,689 (15.2%)
                  klass_megamorphic: 40,675,817 ( 7.5%)
                     iseq_has_no_kw: 37,771,333 ( 6.9%)
                    args_splat_ivar: 30,390,897 ( 5.6%)
          args_splat_cfunc_var_args: 25,287,339 ( 4.6%)
                          block_arg: 14,918,890 ( 2.7%)
                      zsuper_method: 14,838,000 ( 2.7%)
                   iseq_arity_error: 14,485,930 ( 2.7%)
                        not_fixnums: 14,467,830 ( 2.7%)
                args_splat_opt_call:  9,294,140 ( 1.7%)
                           keywords:  8,695,549 ( 1.6%)
                         send_chain:  6,718,814 ( 1.2%)
                        send_getter:  5,628,936 ( 1.0%)
                        iseq_zsuper:  3,957,430 ( 0.7%)
                       mid_mismatch:  3,490,123 ( 0.6%)
                    ivar_set_method:  1,681,428 ( 0.3%)
                is_a_class_mismatch:    630,974 ( 0.1%)
           iseq_missing_optional_kw:    588,419 ( 0.1%)
    args_splat_cfunc_ruby2_keywords:    479,239 ( 0.1%)
              send_chain_not_string:    425,260 ( 0.1%)
         instance_of_class_mismatch:    404,002 ( 0.1%)
                 iseq_splat_with_kw:    342,420 ( 0.1%)
              cfunc_ruby_array_varg:    202,462 ( 0.0%)
            iseq_materialized_block:    196,259 ( 0.0%)
        iseq_has_rest_opt_and_block:    194,387 ( 0.0%)
             iseq_has_rest_and_send:    147,423 ( 0.0%)
        optimized_method_block_call:    112,669 ( 0.0%)
                        interrupted:    106,689 ( 0.0%)
             args_splat_cfunc_zuper:    106,666 ( 0.0%)
                     refined_method:     56,767 ( 0.0%)
                         call_kwarg:      1,594 ( 0.0%)
                 cfunc_toomany_args:        236 ( 0.0%)
        splatarray_length_not_equal:         52 ( 0.0%)
invokeblock exit reasons: 
                  proc:  3,539,894 (60.1%)
    iseq_block_changed:  1,715,118 (29.1%)
                symbol:    637,913 (10.8%)
invokesuper exit reasons: 
         block:  3,564,030 (56.0%)
    me_changed:  2,804,991 (44.0%)
leave exit reasons: 
    interp_return: 3,312,802,571 (100.0%)
     se_interrupt:     80,528 ( 0.0%)
getblockparamproxy exit reasons: 
    block_param_modified:    150,158 (100.0%)
getinstancevariable exit reasons:
    megamorphic:      8,561 (100.0%)
setinstancevariable exit reasons:
    (all relevant counters are zero)
definedivar exit reasons:
    (all relevant counters are zero)
opt_aref exit reasons: 
     not_hash:    168,327 (98.9%)
    not_array:      1,812 ( 1.1%)
expandarray exit reasons: 
    rhs_too_small:  7,679,962 (98.1%)
            splat:    107,600 ( 1.4%)
        not_array:     38,513 ( 0.5%)
opt_getinlinecache exit reasons: 
    miss:         99 (100.0%)
invalidation reasons: 
          method_lookup:      1,782 (47.6%)
    constant_state_bump:      1,059 (28.3%)
       constant_ic_fill:        899 (24.0%)
num_send:              27,539,091,296
num_send_known_class:  2,011,466,186 ( 7.3%)
num_send_polymorphic:  7,499,671,938 (27.2%)
num_send_x86_rel32:          174,331
num_send_x86_reg:              1,065
iseq_stack_too_large:              0
iseq_too_long:                     0
temp_reg_opnd:               962,985
temp_mem_opnd:               705,639
temp_spill:                  616,263
bindings_allocations:         26,822
bindings_set:                  6,236
compiled_iseq_count:          12,220
compiled_blockid_count:      117,997
compiled_block_count:        193,349
versions_per_block:            1.639
compiled_branch_count:       372,128
block_next_count:            179,607
defer_count:                  53,866
defer_empty_count:            14,506
branch_insn_count:            15,109
branch_known_count:            3,478 (23.0%)
freed_iseq_count:                  2
invalidation_count:            3,740
constant_state_bumps:              0
get_ivar_max_depth:      202,816,588
inline_code_size:         20,084,594
outlined_code_size:       18,206,022
code_region_size:         39,813,120
freed_code_size:                   0
yjit_alloc_size:          82,911,029
live_context_size:         9,440,080
live_context_count:          325,520
live_page_count:               2,430
freed_page_count:                  0
code_gc_count:                     0
num_gc_obj_refs:             168,689
object_shape_count:           12,661
side_exit_count:         579,706,989
total_exit_count:      3,892,509,560
total_insns_count:     153,027,715,476
vm_insns_count:        10,042,681,460
yjit_insns_count:      143,564,741,005
ratio_in_yjit:                 93.4%
avg_len_in_yjit:                36.7
Top-20 most frequent exit ops (100.0% of exits):
    opt_send_without_block: 343,236,814 (59.2%)
                      send: 142,985,861 (24.7%)
               invokesuper: 37,283,738 ( 6.4%)
               invokeblock: 20,378,855 ( 3.5%)
                    opt_eq: 13,894,669 ( 2.4%)
               expandarray:  7,826,075 ( 1.4%)
       setinstancevariable:  6,351,328 ( 1.1%)
                checkmatch:  2,421,566 ( 0.4%)
        getblockparamproxy:  1,452,102 ( 0.3%)
             setlocal_WC_0:  1,369,166 ( 0.2%)
      opt_getconstant_path:  1,126,081 ( 0.2%)
                  opt_aref:    458,485 ( 0.1%)
             opt_aref_with:    350,915 ( 0.1%)
             opt_aset_with:    117,266 ( 0.0%)
                      once:    109,614 ( 0.0%)
             setblockparam:     88,404 ( 0.0%)
                     leave:     80,528 ( 0.0%)
                 opt_nil_p:     59,510 ( 0.0%)
           newarraykwsplat:     51,163 ( 0.0%)
                   opt_not:     20,493 ( 0.0%)

@maximecb
Copy link
Contributor

Very nice! Well done! :D

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants