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: Initial implementation of splat with optional params #7166

Merged
merged 1 commit into from Jan 30, 2023

Conversation

jimmyhmiller
Copy link
Contributor

Big highlight here is reduction of iseq_splat_with_opt on railsbench from 15448. Instead we get 2029 exits for splatarray_length_not_equal. I can definitely implement it so we get rid of most (all?) of those exits as well. But wanted to keep it simple.

Before
ruby 3.3.0dev (2023-01-19T21:26:32Z upstream/master 0949cd7107) +YJIT dev [arm64-darwin22]
Command: bundle check 2> /dev/null || bundle install
The Gemfile's dependencies are satisfied
Command: bin/rails db:migrate db:seed
Using 100 posts in the database
***YJIT: Printing YJIT statistics on exit***
method call exit reasons: 
                      iseq_has_rest     107992 (31.0%)
                          block_arg      64622 (18.6%)
                        iseq_zsuper      46081 (13.2%)
                   iseq_arity_error      28708 ( 8.2%)
                iseq_ruby2_keywords      24995 ( 7.2%)
          args_splat_cfunc_var_args      16250 ( 4.7%)
                     iseq_has_no_kw      15971 ( 4.6%)
                iseq_splat_with_opt      15448 ( 4.4%)
                           kw_splat      12995 ( 3.7%)
                    iseq_has_kwrest       5294 ( 1.5%)
           iseq_missing_optional_kw       4054 ( 1.2%)
             args_splat_cfunc_zuper       2002 ( 0.6%)
                      iseq_has_post       1987 ( 0.6%)
                     refined_method        891 ( 0.3%)
              cfunc_ruby_array_varg        651 ( 0.2%)
                           keywords        102 ( 0.0%)
    args_splat_cfunc_ruby2_keywords         62 ( 0.0%)
                    args_splat_ivar         49 ( 0.0%)
                        send_getter         12 ( 0.0%)
                      zsuper_method          9 ( 0.0%)
               args_splat_optimized          5 ( 0.0%)
                    ivar_set_method          2 ( 0.0%)
                  bmethod_block_arg          2 ( 0.0%)
invokeblock exit reasons: 
               ifunc       5798 (56.1%)
                proc       2363 (22.9%)
     iseq_arg0_splat       2000 (19.4%)
    iseq_tag_changed        102 ( 1.0%)
              symbol         68 ( 0.7%)
invokesuper exit reasons: 
         block       4846 (98.2%)
    me_changed         87 ( 1.8%)
leave exit reasons: 
        interp_return    1847560 (97.7%)
    start_pc_non_zero      43884 ( 2.3%)
         se_interrupt         33 ( 0.0%)
getblockparamproxy exit reasons: 
    block_param_modified          3 (100.0%)
getinstancevariable exit reasons:
    megamorphic      13685 (100.0%)
setinstancevariable exit reasons:
    (all relevant counters are zero)
opt_aref exit reasons: 
    (all relevant counters are zero)
expandarray exit reasons: 
            splat       9974 (99.8%)
    rhs_too_small         22 ( 0.2%)
opt_getinlinecache exit reasons: 
    miss         11 (100.0%)
invalidation reasons: 
       constant_ic_fill       2006 (59.2%)
          method_lookup       1044 (30.8%)
    constant_state_bump        337 ( 9.9%)
bindings_allocations:         180
bindings_set:                   0
compiled_iseq_count:         9282
compiled_block_count:       51937
compiled_branch_count:      82230
block_next_count:           15168
defer_count:                16330
freed_iseq_count:            4051
invalidation_count:          3387
constant_state_bumps:           0
inline_code_size:         8815520
outlined_code_size:       8812960
freed_code_size:                0
code_region_size:        17678336
yjit_alloc_size:         98055804
live_page_count:             1079
freed_page_count:               0
code_gc_count:                  0
num_gc_obj_refs:            41265
object_shape_count:          2396
side_exit_count:           522816
total_exit_count:         2370376
total_insns_count:       89888726
vm_insns_count:           8734613
yjit_insns_count:        81676929
ratio_in_yjit:              90.3%
avg_len_in_yjit:             34.2
Top-20 most frequent exit ops (100.0% of exits):
    opt_send_without_block:     155299 (29.7%)
               invokesuper:     117065 (22.4%)
                      send:     104087 (19.9%)
      opt_getconstant_path:      53736 (10.3%)
               invokeblock:      37015 (7.1%)
                  opt_aref:      14087 (2.7%)
                     throw:      10587 (2.0%)
               expandarray:       9996 (1.9%)
             setlocal_WC_0:       8357 (1.6%)
                    opt_eq:       5009 (1.0%)
       getinstancevariable:       3485 (0.7%)
        getblockparamproxy:       2271 (0.4%)
               objtostring:        448 (0.1%)
          putspecialobject:        386 (0.1%)
                 opt_nil_p:        327 (0.1%)
             definesmethod:        240 (0.0%)
                checkmatch:        204 (0.0%)
                      once:        104 (0.0%)
                     leave:         34 (0.0%)
               opt_empty_p:         31 (0.0%)
itr #1: 5320ms
After
ruby 3.3.0dev (2023-01-19T22:11:54Z yjit-splat-opt-2 1704dd6a06) +YJIT dev [arm64-darwin22]
Command: bundle check 2> /dev/null || bundle install
The Gemfile's dependencies are satisfied
Command: bin/rails db:migrate db:seed
Using 100 posts in the database
***YJIT: Printing YJIT statistics on exit***
method call exit reasons: 
                      iseq_has_rest     107994 (32.3%)
                          block_arg      64624 (19.3%)
                        iseq_zsuper      46081 (13.8%)
                   iseq_arity_error      28708 ( 8.6%)
                iseq_ruby2_keywords      24995 ( 7.5%)
          args_splat_cfunc_var_args      16250 ( 4.9%)
                     iseq_has_no_kw      15971 ( 4.8%)
                           kw_splat      12995 ( 3.9%)
                    iseq_has_kwrest       5294 ( 1.6%)
           iseq_missing_optional_kw       4054 ( 1.2%)
        splatarray_length_not_equal       2029 ( 0.6%)
             args_splat_cfunc_zuper       2002 ( 0.6%)
                      iseq_has_post       1987 ( 0.6%)
                     refined_method        891 ( 0.3%)
              cfunc_ruby_array_varg        651 ( 0.2%)
                           keywords        102 ( 0.0%)
    args_splat_cfunc_ruby2_keywords         62 ( 0.0%)
                    args_splat_ivar         49 ( 0.0%)
                        send_getter         12 ( 0.0%)
                      zsuper_method          9 ( 0.0%)
               args_splat_optimized          5 ( 0.0%)
                    ivar_set_method          2 ( 0.0%)
                  bmethod_block_arg          2 ( 0.0%)
invokeblock exit reasons: 
               ifunc       5798 (56.1%)
                proc       2363 (22.9%)
     iseq_arg0_splat       2000 (19.4%)
    iseq_tag_changed        102 ( 1.0%)
              symbol         68 ( 0.7%)
invokesuper exit reasons: 
         block       4846 (98.3%)
    me_changed         86 ( 1.7%)
leave exit reasons: 
        interp_return    1847554 (97.7%)
    start_pc_non_zero      43886 ( 2.3%)
         se_interrupt         32 ( 0.0%)
getblockparamproxy exit reasons: 
    block_param_modified          3 (100.0%)
getinstancevariable exit reasons:
    megamorphic      13685 (100.0%)
setinstancevariable exit reasons:
    (all relevant counters are zero)
opt_aref exit reasons: 
    (all relevant counters are zero)
expandarray exit reasons: 
            splat       9974 (99.8%)
    rhs_too_small         22 ( 0.2%)
opt_getinlinecache exit reasons: 
    miss         11 (100.0%)
invalidation reasons: 
       constant_ic_fill       2008 (59.3%)
          method_lookup       1044 (30.8%)
    constant_state_bump        337 ( 9.9%)
bindings_allocations:         180
bindings_set:                   0
compiled_iseq_count:         9282
compiled_block_count:       51979
compiled_branch_count:      82304
block_next_count:           15179
defer_count:                16349
freed_iseq_count:            4052
invalidation_count:          3389
constant_state_bumps:           0
inline_code_size:         9056252
outlined_code_size:       9055664
freed_code_size:                0
code_region_size:        18169856
yjit_alloc_size:         98172237
live_page_count:             1109
freed_page_count:               0
code_gc_count:                  0
num_gc_obj_refs:            41318
object_shape_count:          2396
side_exit_count:           509398
total_exit_count:         2356952
total_insns_count:       89898928
vm_insns_count:           8721130
yjit_insns_count:        81687196
ratio_in_yjit:              90.3%
avg_len_in_yjit:             34.4
Top-20 most frequent exit ops (100.0% of exits):
    opt_send_without_block:     141940 (27.9%)
               invokesuper:     117064 (23.0%)
                      send:     104029 (20.4%)
      opt_getconstant_path:      53736 (10.5%)
               invokeblock:      37015 (7.3%)
                  opt_aref:      14087 (2.8%)
                     throw:      10587 (2.1%)
               expandarray:       9996 (2.0%)
             setlocal_WC_0:       8358 (1.6%)
                    opt_eq:       5008 (1.0%)
       getinstancevariable:       3485 (0.7%)
        getblockparamproxy:       2271 (0.4%)
               objtostring:        448 (0.1%)
          putspecialobject:        386 (0.1%)
                 opt_nil_p:        327 (0.1%)
             definesmethod:        240 (0.0%)
                checkmatch:        204 (0.0%)
                      once:        104 (0.0%)
                     leave:         33 (0.0%)
               opt_empty_p:         31 (0.0%)
itr #1: 5523ms

@matzbot matzbot requested a review from a team January 20, 2023 21:25
@maximecb maximecb merged commit b32e116 into ruby:master Jan 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants