94589 Commits

Author SHA1 Message Date
Burdette Lamar
862b42a52c
[DOC] Tweaks for String#scrub! (#14893) 2025-10-21 16:46:40 -04:00
Burdette Lamar
42c0409781
[DOC] Tweaks for String#scan (#14884) 2025-10-21 16:44:41 -04:00
Burdette Lamar
caff9b9065
[DOC] Tweaks for String#rstrip (#14881) 2025-10-21 16:44:03 -04:00
BurdetteLamar
3b87e76cc6 [DOC] Tweaks for String#rpartition 2025-10-20 21:38:18 -04:00
BurdetteLamar
e930bd3eae [DOC] Tweaks for String#rstrip! 2025-10-20 21:37:26 -04:00
Max Bernstein
17368234bf
ZJIT: Implement codegen for FixnumMod (#14857)
This is mostly to see what happens to the loops-times benchmark.
2025-10-20 21:30:48 +00:00
Luke Gruber
6e9f7974df [DOC] Create doc/contributing/concurrency_guide.md
This guide is for those that want to contribute to ruby but don't
understand where they need to use locks or other concurrency mechanisms.
It teaches them how to use these locks safely and what is prohibited in
certain circumstances.
2025-10-20 13:55:39 -07:00
Stan Lo
e047cea280
ZJIT: Optimize send with block into CCallWithFrame (#14863)
Since `Send` has a block iseq, I updated `CCallWithFrame` to take an optional `blockiseq` as well, and then generate `CCallWithFrame` for `Send` when the condition is right.

## Stats

`liquid-render` Benchmark

  | Metric               | Before             | After              | Change  |
  |----------------------|--------------------|--------------------|--------------------- |
  | send_no_profiles     | 3,209,418 (34.1%)  | 4,119 (0.1%)       | -3,205,299 (-99.9%) |
  | dynamic_send_count   | 9,410,758 (23.1%)  | 6,459,678 (15.9%)  | -2,951,080 (-31.4%) |
  | optimized_send_count | 31,269,388 (76.9%) | 34,220,474 (84.1%) | +2,951,086 (+9.4%) |

`lobsters` Benchmark

  | Metric               | Before     | After      | Change              |
  |----------------------|------------|------------|---------------------|
  | send_no_profiles     | 10,769,052 | 2,902,865  | -7,866,187 (-73.0%) |
  | dynamic_send_count   | 45,673,185 | 42,880,160 | -2,793,025 (-6.1%)  |
  | optimized_send_count | 75,142,407 | 78,378,514 | +3,236,107 (+4.3%)  |


### `liquid-render` Before

<details>

```
Average of last 22, non-warmup iters: 262ms
***ZJIT: Printing ZJIT statistics on exit***
Top-20 not inlined C methods (96.9% of total 10,370,809):
                    Kernel#respond_to?: 5,069,204 (48.9%)
                             Hash#key?: 2,394,488 (23.1%)
                          Set#include?:   778,429 ( 7.5%)
                            String#===:   326,134 ( 3.1%)
                             String#<<:   203,231 ( 2.0%)
                            Integer#<<:   166,768 ( 1.6%)
                          Kernel#is_a?:   164,272 ( 1.6%)
                         Kernel#format:   124,262 ( 1.2%)
                             Integer#/:   124,262 ( 1.2%)
                              Array#<<:   115,325 ( 1.1%)
                     Regexp.last_match:    94,862 ( 0.9%)
                              Hash#[]=:    88,485 ( 0.9%)
                    String#start_with?:    55,933 ( 0.5%)
             CGI::EscapeExt#escapeHTML:    55,471 ( 0.5%)
                           Array#shift:    55,298 ( 0.5%)
                            Regexp#===:    48,928 ( 0.5%)
                             String#=~:    48,477 ( 0.5%)
                         Array#unshift:    47,331 ( 0.5%)
                         String#empty?:    42,870 ( 0.4%)
                            Array#push:    41,215 ( 0.4%)
Top-20 not annotated C methods (97.1% of total 10,394,421):
                    Kernel#respond_to?: 5,069,204 (48.8%)
                             Hash#key?: 2,394,488 (23.0%)
                          Set#include?:   778,429 ( 7.5%)
                            String#===:   326,134 ( 3.1%)
                          Kernel#is_a?:   208,664 ( 2.0%)
                             String#<<:   203,231 ( 2.0%)
                            Integer#<<:   166,768 ( 1.6%)
                             Integer#/:   124,262 ( 1.2%)
                         Kernel#format:   124,262 ( 1.2%)
                              Array#<<:   115,325 ( 1.1%)
                     Regexp.last_match:    94,862 ( 0.9%)
                              Hash#[]=:    88,485 ( 0.9%)
                    String#start_with?:    55,933 ( 0.5%)
             CGI::EscapeExt#escapeHTML:    55,471 ( 0.5%)
                           Array#shift:    55,298 ( 0.5%)
                            Regexp#===:    48,928 ( 0.5%)
                             String#=~:    48,477 ( 0.5%)
                         Array#unshift:    47,331 ( 0.5%)
                         String#empty?:    42,870 ( 0.4%)
                            Array#push:    41,215 ( 0.4%)
Top-2 not optimized method types for send (100.0% of total 2,382):
  cfunc: 1,196 (50.2%)
   iseq: 1,186 (49.8%)
Top-4 not optimized method types for send_without_block (100.0% of total 2,561,006):
       iseq: 2,442,091 (95.4%)
  optimized:   118,882 ( 4.6%)
      alias:        20 ( 0.0%)
       null:        13 ( 0.0%)
Top-9 not optimized instructions (100.0% of total 685,128):
             invokeblock: 227,376 (33.2%)
                 opt_neq: 166,471 (24.3%)
                 opt_and: 166,471 (24.3%)
                  opt_eq:  66,721 ( 9.7%)
             invokesuper:  39,363 ( 5.7%)
                  opt_le:  16,278 ( 2.4%)
               opt_minus:   1,574 ( 0.2%)
  opt_send_without_block:     772 ( 0.1%)
                  opt_or:     102 ( 0.0%)
Top-8 send fallback reasons (100.0% of total 9,410,758):
                              send_no_profiles: 3,209,418 (34.1%)
                send_without_block_polymorphic: 2,858,558 (30.4%)
  send_without_block_not_optimized_method_type: 2,561,006 (27.2%)
                     not_optimized_instruction:   685,128 ( 7.3%)
                send_without_block_no_profiles:    91,913 ( 1.0%)
                send_not_optimized_method_type:     2,382 ( 0.0%)
                      obj_to_string_not_string:     2,352 ( 0.0%)
       send_without_block_cfunc_array_variadic:         1 ( 0.0%)
Top-3 unhandled YARV insns (100.0% of total 83,682):
  getclassvariable: 83,431 (99.7%)
              once:    137 ( 0.2%)
       getconstant:    114 ( 0.1%)
Top-3 compile error reasons (100.0% of total 5,431,910):
  register_spill_on_alloc: 4,665,393 (85.9%)
        exception_handler:   766,347 (14.1%)
  register_spill_on_ccall:       170 ( 0.0%)
Top-11 side exit reasons (100.0% of total 14,635,508):
                        compile_error: 5,431,910 (37.1%)
                  guard_shape_failure: 3,436,341 (23.5%)
                   guard_type_failure: 2,545,791 (17.4%)
                      unhandled_splat: 2,162,907 (14.8%)
                      unhandled_kwarg:   952,568 ( 6.5%)
                  unhandled_yarv_insn:    83,682 ( 0.6%)
                   unhandled_hir_insn:    19,112 ( 0.1%)
     patchpoint_stable_constant_names:     1,608 ( 0.0%)
               obj_to_string_fallback:       902 ( 0.0%)
          patchpoint_method_redefined:       599 ( 0.0%)
  block_param_proxy_not_iseq_or_ifunc:        88 ( 0.0%)
                             send_count: 40,680,153
                     dynamic_send_count:  9,410,758 (23.1%)
                   optimized_send_count: 31,269,395 (76.9%)
              iseq_optimized_send_count: 13,886,902 (34.1%)
      inline_cfunc_optimized_send_count:  7,011,684 (17.2%)
non_variadic_cfunc_optimized_send_count:  4,670,333 (11.5%)
    variadic_cfunc_optimized_send_count:  5,700,476 (14.0%)
dynamic_getivar_count:                         1,144,613
dynamic_setivar_count:                           950,830
compiled_iseq_count:                                 402
failed_iseq_count:                                    48
compile_time:                                      976ms
profile_time:                                    3,223ms
gc_time:                                            22ms
invalidation_time:                                   0ms
vm_write_pc_count:                            37,744,491
vm_write_sp_count:                            37,511,865
vm_write_locals_count:                        37,511,865
vm_write_stack_count:                         37,511,865
vm_write_to_parent_iseq_local_count:             558,177
vm_read_from_parent_iseq_local_count:         14,317,032
code_region_bytes:                             2,211,840
side_exit_count:                              14,635,508
total_insn_count:                            476,097,972
vm_insn_count:                               253,795,154
zjit_insn_count:                             222,302,818
ratio_in_zjit:                                     46.7%
```

</details>

### `liquid-render` After

<details>

```
Average of last 21, non-warmup iters: 272ms
***ZJIT: Printing ZJIT statistics on exit***
Top-20 not inlined C methods (96.8% of total 10,093,966):
                    Kernel#respond_to?: 4,932,224 (48.9%)
                             Hash#key?: 2,329,928 (23.1%)
                          Set#include?:   757,389 ( 7.5%)
                            String#===:   317,494 ( 3.1%)
                             String#<<:   197,831 ( 2.0%)
                            Integer#<<:   162,268 ( 1.6%)
                          Kernel#is_a?:   159,892 ( 1.6%)
                         Kernel#format:   120,902 ( 1.2%)
                             Integer#/:   120,902 ( 1.2%)
                              Array#<<:   112,225 ( 1.1%)
                     Regexp.last_match:    92,382 ( 0.9%)
                              Hash#[]=:    86,145 ( 0.9%)
                    String#start_with?:    54,953 ( 0.5%)
                           Array#shift:    54,038 ( 0.5%)
             CGI::EscapeExt#escapeHTML:    53,971 ( 0.5%)
                            Regexp#===:    47,848 ( 0.5%)
                             String#=~:    47,237 ( 0.5%)
                         Array#unshift:    46,051 ( 0.5%)
                         String#empty?:    41,750 ( 0.4%)
                            Array#push:    40,115 ( 0.4%)
Top-20 not annotated C methods (97.1% of total 10,116,938):
                    Kernel#respond_to?: 4,932,224 (48.8%)
                             Hash#key?: 2,329,928 (23.0%)
                          Set#include?:   757,389 ( 7.5%)
                            String#===:   317,494 ( 3.1%)
                          Kernel#is_a?:   203,084 ( 2.0%)
                             String#<<:   197,831 ( 2.0%)
                            Integer#<<:   162,268 ( 1.6%)
                         Kernel#format:   120,902 ( 1.2%)
                             Integer#/:   120,902 ( 1.2%)
                              Array#<<:   112,225 ( 1.1%)
                     Regexp.last_match:    92,382 ( 0.9%)
                              Hash#[]=:    86,145 ( 0.9%)
                    String#start_with?:    54,953 ( 0.5%)
                           Array#shift:    54,038 ( 0.5%)
             CGI::EscapeExt#escapeHTML:    53,971 ( 0.5%)
                            Regexp#===:    47,848 ( 0.5%)
                             String#=~:    47,237 ( 0.5%)
                         Array#unshift:    46,051 ( 0.5%)
                         String#empty?:    41,750 ( 0.4%)
                            Array#push:    40,115 ( 0.4%)
Top-2 not optimized method types for send (100.0% of total 182,938):
   iseq: 178,414 (97.5%)
  cfunc:   4,524 ( 2.5%)
Top-4 not optimized method types for send_without_block (100.0% of total 2,492,246):
       iseq: 2,376,511 (95.4%)
  optimized:   115,702 ( 4.6%)
      alias:        20 ( 0.0%)
       null:        13 ( 0.0%)
Top-9 not optimized instructions (100.0% of total 667,727):
             invokeblock: 221,375 (33.2%)
                 opt_neq: 161,971 (24.3%)
                 opt_and: 161,971 (24.3%)
                  opt_eq:  64,921 ( 9.7%)
             invokesuper:  39,243 ( 5.9%)
                  opt_le:  15,838 ( 2.4%)
               opt_minus:   1,534 ( 0.2%)
  opt_send_without_block:     772 ( 0.1%)
                  opt_or:     102 ( 0.0%)
Top-9 send fallback reasons (100.0% of total 6,287,956):
                send_without_block_polymorphic: 2,782,058 (44.2%)
  send_without_block_not_optimized_method_type: 2,492,246 (39.6%)
                     not_optimized_instruction:   667,727 (10.6%)
                send_not_optimized_method_type:   182,938 ( 2.9%)
                send_without_block_no_profiles:    89,613 ( 1.4%)
                              send_polymorphic:    66,962 ( 1.1%)
                              send_no_profiles:     4,059 ( 0.1%)
                      obj_to_string_not_string:     2,352 ( 0.0%)
       send_without_block_cfunc_array_variadic:         1 ( 0.0%)
Top-3 unhandled YARV insns (100.0% of total 81,482):
  getclassvariable: 81,231 (99.7%)
              once:    137 ( 0.2%)
       getconstant:    114 ( 0.1%)
Top-3 compile error reasons (100.0% of total 5,286,310):
  register_spill_on_alloc: 4,540,413 (85.9%)
        exception_handler:   745,727 (14.1%)
  register_spill_on_ccall:       170 ( 0.0%)
Top-12 side exit reasons (100.0% of total 14,244,881):
                        compile_error: 5,286,310 (37.1%)
                  guard_shape_failure: 3,346,873 (23.5%)
                   guard_type_failure: 2,477,071 (17.4%)
                      unhandled_splat: 2,104,447 (14.8%)
                      unhandled_kwarg:   926,828 ( 6.5%)
                  unhandled_yarv_insn:    81,482 ( 0.6%)
                   unhandled_hir_insn:    18,672 ( 0.1%)
     patchpoint_stable_constant_names:     1,608 ( 0.0%)
               obj_to_string_fallback:       902 ( 0.0%)
          patchpoint_method_redefined:       599 ( 0.0%)
  block_param_proxy_not_iseq_or_ifunc:        88 ( 0.0%)
                            interrupt:         1 ( 0.0%)
                             send_count: 39,591,410
                     dynamic_send_count:  6,287,956 (15.9%)
                   optimized_send_count: 33,303,454 (84.1%)
              iseq_optimized_send_count: 13,514,283 (34.1%)
      inline_cfunc_optimized_send_count:  6,823,745 (17.2%)
non_variadic_cfunc_optimized_send_count:  7,417,432 (18.7%)
    variadic_cfunc_optimized_send_count:  5,547,994 (14.0%)
dynamic_getivar_count:                        1,110,647
dynamic_setivar_count:                          927,309
compiled_iseq_count:                                403
failed_iseq_count:                                   48
compile_time:                                     968ms
profile_time:                                   3,547ms
gc_time:                                           22ms
invalidation_time:                                  0ms
vm_write_pc_count:                           36,735,108
vm_write_sp_count:                           36,508,262
vm_write_locals_count:                       36,508,262
vm_write_stack_count:                        36,508,262
vm_write_to_parent_iseq_local_count:            543,097
vm_read_from_parent_iseq_local_count:        13,930,672
code_region_bytes:                            2,228,224
side_exit_count:                             14,244,881
total_insn_count:                           463,357,969
vm_insn_count:                              247,003,727
zjit_insn_count:                            216,354,242
ratio_in_zjit:                                    46.7%
```

</details>

### `lobsters` Before

<details>

```
Average of last 10, non-warmup iters: 898ms
***ZJIT: Printing ZJIT statistics on exit***
Top-20 not inlined C methods (61.3% of total 19,495,906):
                                  String#<<: 1,764,437 ( 9.1%)
                               Kernel#is_a?: 1,615,120 ( 8.3%)
                                   Hash#[]=: 1,159,455 ( 5.9%)
                              Regexp#match?:   777,496 ( 4.0%)
                              String#empty?:   722,953 ( 3.7%)
                                  Hash#key?:   685,258 ( 3.5%)
                         Kernel#respond_to?:   602,017 ( 3.1%)
                              TrueClass#===:   447,671 ( 2.3%)
                             FalseClass#===:   439,276 ( 2.3%)
                             Array#include?:   426,758 ( 2.2%)
                        Kernel#block_given?:   405,271 ( 2.1%)
                                 Hash#fetch:   382,302 ( 2.0%)
                 ObjectSpace::WeakKeyMap#[]:   356,654 ( 1.8%)
                         String#start_with?:   353,793 ( 1.8%)
                            Kernel#kind_of?:   340,341 ( 1.7%)
                                 Kernel#dup:   328,162 ( 1.7%)
                                 String.new:   306,667 ( 1.6%)
                                  String#==:   287,549 ( 1.5%)
                             BasicObject#!=:   284,642 ( 1.5%)
                              String#length:   256,070 ( 1.3%)
Top-20 not annotated C methods (62.4% of total 19,796,172):
                               Kernel#is_a?: 1,993,676 (10.1%)
                                  String#<<: 1,764,437 ( 8.9%)
                                   Hash#[]=: 1,159,634 ( 5.9%)
                              Regexp#match?:   777,496 ( 3.9%)
                              String#empty?:   738,030 ( 3.7%)
                                  Hash#key?:   685,258 ( 3.5%)
                         Kernel#respond_to?:   602,017 ( 3.0%)
                              TrueClass#===:   447,671 ( 2.3%)
                             FalseClass#===:   439,276 ( 2.2%)
                             Array#include?:   426,758 ( 2.2%)
                        Kernel#block_given?:   425,813 ( 2.2%)
                                 Hash#fetch:   382,302 ( 1.9%)
                 ObjectSpace::WeakKeyMap#[]:   356,654 ( 1.8%)
                         String#start_with?:   353,793 ( 1.8%)
                            Kernel#kind_of?:   340,375 ( 1.7%)
                                 Kernel#dup:   328,169 ( 1.7%)
                                 String.new:   306,667 ( 1.5%)
                                  String#==:   293,520 ( 1.5%)
                             BasicObject#!=:   284,825 ( 1.4%)
                              String#length:   256,070 ( 1.3%)
Top-2 not optimized method types for send (100.0% of total 115,007):
  cfunc: 76,172 (66.2%)
   iseq: 38,835 (33.8%)
Top-6 not optimized method types for send_without_block (100.0% of total 8,003,641):
       iseq: 3,999,211 (50.0%)
    bmethod: 1,750,271 (21.9%)
  optimized: 1,653,426 (20.7%)
      alias:   591,342 ( 7.4%)
       null:     8,174 ( 0.1%)
      cfunc:     1,217 ( 0.0%)
Top-13 not optimized instructions (100.0% of total 7,590,826):
             invokesuper: 4,335,446 (57.1%)
             invokeblock: 1,329,215 (17.5%)
             sendforward:   841,463 (11.1%)
                  opt_eq:   810,614 (10.7%)
                opt_plus:   141,773 ( 1.9%)
               opt_minus:    52,270 ( 0.7%)
  opt_send_without_block:    43,248 ( 0.6%)
                 opt_neq:    15,047 ( 0.2%)
                opt_mult:    13,824 ( 0.2%)
                  opt_or:     7,451 ( 0.1%)
                  opt_lt:       348 ( 0.0%)
                  opt_ge:        91 ( 0.0%)
                  opt_gt:        36 ( 0.0%)
Top-9 send fallback reasons (100.0% of total 45,673,212):
                send_without_block_polymorphic: 17,390,335 (38.1%)
                              send_no_profiles: 10,769,053 (23.6%)
  send_without_block_not_optimized_method_type:  8,003,641 (17.5%)
                     not_optimized_instruction:  7,590,826 (16.6%)
                send_without_block_no_profiles:  1,757,109 ( 3.8%)
                send_not_optimized_method_type:    115,007 ( 0.3%)
       send_without_block_cfunc_array_variadic:     31,149 ( 0.1%)
                      obj_to_string_not_string:     15,518 ( 0.0%)
       send_without_block_direct_too_many_args:        574 ( 0.0%)
Top-9 unhandled YARV insns (100.0% of total 1,242,228):
         expandarray: 622,203 (50.1%)
        checkkeyword: 316,111 (25.4%)
    getclassvariable: 120,540 ( 9.7%)
       getblockparam:  88,480 ( 7.1%)
  invokesuperforward:  78,842 ( 6.3%)
   opt_duparray_send:  14,149 ( 1.1%)
         getconstant:   1,588 ( 0.1%)
          checkmatch:     288 ( 0.0%)
                once:      27 ( 0.0%)
Top-3 compile error reasons (100.0% of total 6,769,693):
  register_spill_on_alloc: 6,188,305 (91.4%)
  register_spill_on_ccall:   347,108 ( 5.1%)
        exception_handler:   234,280 ( 3.5%)
Top-17 side exit reasons (100.0% of total 20,142,827):
                        compile_error: 6,769,693 (33.6%)
                   guard_type_failure: 5,169,050 (25.7%)
                  guard_shape_failure: 3,726,362 (18.5%)
                  unhandled_yarv_insn: 1,242,228 ( 6.2%)
  block_param_proxy_not_iseq_or_ifunc:   984,480 ( 4.9%)
                      unhandled_kwarg:   800,154 ( 4.0%)
                unknown_newarray_send:   539,317 ( 2.7%)
     patchpoint_stable_constant_names:   340,283 ( 1.7%)
                      unhandled_splat:   229,440 ( 1.1%)
                   unhandled_hir_insn:   147,351 ( 0.7%)
        patchpoint_no_singleton_class:   128,856 ( 0.6%)
          patchpoint_method_redefined:    32,718 ( 0.2%)
           block_param_proxy_modified:    25,274 ( 0.1%)
              patchpoint_no_ep_escape:     7,559 ( 0.0%)
               obj_to_string_fallback:        24 ( 0.0%)
               guard_type_not_failure:        22 ( 0.0%)
                            interrupt:        16 ( 0.0%)
                             send_count: 120,815,640
                     dynamic_send_count:  45,673,212 (37.8%)
                   optimized_send_count:  75,142,428 (62.2%)
              iseq_optimized_send_count:  32,188,039 (26.6%)
      inline_cfunc_optimized_send_count:  23,458,483 (19.4%)
non_variadic_cfunc_optimized_send_count:  14,809,797 (12.3%)
    variadic_cfunc_optimized_send_count:   4,686,109 ( 3.9%)
dynamic_getivar_count:                       13,023,437
dynamic_setivar_count:                       12,311,158
compiled_iseq_count:                              4,806
failed_iseq_count:                                  466
compile_time:                                   8,943ms
profile_time:                                      99ms
gc_time:                                           45ms
invalidation_time:                                239ms
vm_write_pc_count:                          113,652,291
vm_write_sp_count:                          111,209,623
vm_write_locals_count:                      111,209,623
vm_write_stack_count:                       111,209,623
vm_write_to_parent_iseq_local_count:            516,800
vm_read_from_parent_iseq_local_count:        11,225,587
code_region_bytes:                           22,609,920
side_exit_count:                             20,142,827
total_insn_count:                           926,088,942
vm_insn_count:                              297,636,255
zjit_insn_count:                            628,452,687
ratio_in_zjit:                                    67.9%
```

</details> 

### `lobsters` After

<details>

```
Average of last 10, non-warmup iters: 919ms
***ZJIT: Printing ZJIT statistics on exit***
Top-20 not inlined C methods (61.3% of total 19,495,868):
                                  String#<<: 1,764,437 ( 9.1%)
                               Kernel#is_a?: 1,615,110 ( 8.3%)
                                   Hash#[]=: 1,159,455 ( 5.9%)
                              Regexp#match?:   777,496 ( 4.0%)
                              String#empty?:   722,953 ( 3.7%)
                                  Hash#key?:   685,258 ( 3.5%)
                         Kernel#respond_to?:   602,016 ( 3.1%)
                              TrueClass#===:   447,671 ( 2.3%)
                             FalseClass#===:   439,276 ( 2.3%)
                             Array#include?:   426,758 ( 2.2%)
                        Kernel#block_given?:   405,271 ( 2.1%)
                                 Hash#fetch:   382,302 ( 2.0%)
                 ObjectSpace::WeakKeyMap#[]:   356,654 ( 1.8%)
                         String#start_with?:   353,793 ( 1.8%)
                            Kernel#kind_of?:   340,341 ( 1.7%)
                                 Kernel#dup:   328,162 ( 1.7%)
                                 String.new:   306,667 ( 1.6%)
                                  String#==:   287,545 ( 1.5%)
                             BasicObject#!=:   284,642 ( 1.5%)
                              String#length:   256,070 ( 1.3%)
Top-20 not annotated C methods (62.4% of total 19,796,134):
                               Kernel#is_a?: 1,993,666 (10.1%)
                                  String#<<: 1,764,437 ( 8.9%)
                                   Hash#[]=: 1,159,634 ( 5.9%)
                              Regexp#match?:   777,496 ( 3.9%)
                              String#empty?:   738,030 ( 3.7%)
                                  Hash#key?:   685,258 ( 3.5%)
                         Kernel#respond_to?:   602,016 ( 3.0%)
                              TrueClass#===:   447,671 ( 2.3%)
                             FalseClass#===:   439,276 ( 2.2%)
                             Array#include?:   426,758 ( 2.2%)
                        Kernel#block_given?:   425,813 ( 2.2%)
                                 Hash#fetch:   382,302 ( 1.9%)
                 ObjectSpace::WeakKeyMap#[]:   356,654 ( 1.8%)
                         String#start_with?:   353,793 ( 1.8%)
                            Kernel#kind_of?:   340,375 ( 1.7%)
                                 Kernel#dup:   328,169 ( 1.7%)
                                 String.new:   306,667 ( 1.5%)
                                  String#==:   293,516 ( 1.5%)
                             BasicObject#!=:   284,825 ( 1.4%)
                              String#length:   256,070 ( 1.3%)
Top-4 not optimized method types for send (100.0% of total 4,749,678):
   iseq: 2,563,391 (54.0%)
  cfunc: 2,064,888 (43.5%)
  alias:   118,577 ( 2.5%)
   null:     2,822 ( 0.1%)
Top-6 not optimized method types for send_without_block (100.0% of total 8,003,641):
       iseq: 3,999,211 (50.0%)
    bmethod: 1,750,271 (21.9%)
  optimized: 1,653,426 (20.7%)
      alias:   591,342 ( 7.4%)
       null:     8,174 ( 0.1%)
      cfunc:     1,217 ( 0.0%)
Top-13 not optimized instructions (100.0% of total 7,590,818):
             invokesuper: 4,335,442 (57.1%)
             invokeblock: 1,329,215 (17.5%)
             sendforward:   841,463 (11.1%)
                  opt_eq:   810,610 (10.7%)
                opt_plus:   141,773 ( 1.9%)
               opt_minus:    52,270 ( 0.7%)
  opt_send_without_block:    43,248 ( 0.6%)
                 opt_neq:    15,047 ( 0.2%)
                opt_mult:    13,824 ( 0.2%)
                  opt_or:     7,451 ( 0.1%)
                  opt_lt:       348 ( 0.0%)
                  opt_ge:        91 ( 0.0%)
                  opt_gt:        36 ( 0.0%)
Top-10 send fallback reasons (100.0% of total 43,152,037):
                send_without_block_polymorphic: 17,390,322 (40.3%)
  send_without_block_not_optimized_method_type:  8,003,641 (18.5%)
                     not_optimized_instruction:  7,590,818 (17.6%)
                send_not_optimized_method_type:  4,749,678 (11.0%)
                              send_no_profiles:  2,893,666 ( 6.7%)
                send_without_block_no_profiles:  1,757,109 ( 4.1%)
                              send_polymorphic:    719,562 ( 1.7%)
       send_without_block_cfunc_array_variadic:     31,149 ( 0.1%)
                      obj_to_string_not_string:     15,518 ( 0.0%)
       send_without_block_direct_too_many_args:        574 ( 0.0%)
Top-9 unhandled YARV insns (100.0% of total 1,242,215):
         expandarray: 622,203 (50.1%)
        checkkeyword: 316,111 (25.4%)
    getclassvariable: 120,540 ( 9.7%)
       getblockparam:  88,467 ( 7.1%)
  invokesuperforward:  78,842 ( 6.3%)
   opt_duparray_send:  14,149 ( 1.1%)
         getconstant:   1,588 ( 0.1%)
          checkmatch:     288 ( 0.0%)
                once:      27 ( 0.0%)
Top-3 compile error reasons (100.0% of total 6,769,688):
  register_spill_on_alloc: 6,188,305 (91.4%)
  register_spill_on_ccall:   347,108 ( 5.1%)
        exception_handler:   234,275 ( 3.5%)
Top-17 side exit reasons (100.0% of total 20,144,372):
                        compile_error: 6,769,688 (33.6%)
                   guard_type_failure: 5,169,204 (25.7%)
                  guard_shape_failure: 3,726,374 (18.5%)
                  unhandled_yarv_insn: 1,242,215 ( 6.2%)
  block_param_proxy_not_iseq_or_ifunc:   984,480 ( 4.9%)
                      unhandled_kwarg:   800,154 ( 4.0%)
                unknown_newarray_send:   539,317 ( 2.7%)
     patchpoint_stable_constant_names:   340,283 ( 1.7%)
                      unhandled_splat:   229,440 ( 1.1%)
                   unhandled_hir_insn:   147,351 ( 0.7%)
        patchpoint_no_singleton_class:   130,252 ( 0.6%)
          patchpoint_method_redefined:    32,716 ( 0.2%)
           block_param_proxy_modified:    25,274 ( 0.1%)
              patchpoint_no_ep_escape:     7,559 ( 0.0%)
               obj_to_string_fallback:        24 ( 0.0%)
               guard_type_not_failure:        22 ( 0.0%)
                            interrupt:        19 ( 0.0%)
                             send_count: 120,812,030
                     dynamic_send_count:  43,152,037 (35.7%)
                   optimized_send_count:  77,659,993 (64.3%)
              iseq_optimized_send_count:  32,187,900 (26.6%)
      inline_cfunc_optimized_send_count:  23,458,491 (19.4%)
non_variadic_cfunc_optimized_send_count:  17,327,499 (14.3%)
    variadic_cfunc_optimized_send_count:   4,686,103 ( 3.9%)
dynamic_getivar_count:                       13,023,424
dynamic_setivar_count:                       12,310,991
compiled_iseq_count:                              4,806
failed_iseq_count:                                  466
compile_time:                                   9,012ms
profile_time:                                     104ms
gc_time:                                           44ms
invalidation_time:                                239ms
vm_write_pc_count:                          113,648,665
vm_write_sp_count:                          111,205,997
vm_write_locals_count:                      111,205,997
vm_write_stack_count:                       111,205,997
vm_write_to_parent_iseq_local_count:            516,800
vm_read_from_parent_iseq_local_count:        11,225,587
code_region_bytes:                           23,052,288
side_exit_count:                             20,144,372
total_insn_count:                           926,090,214
vm_insn_count:                              297,647,811
zjit_insn_count:                            628,442,403
ratio_in_zjit:                                    67.9%
```

</details>
2025-10-20 20:10:25 +00:00
Max Bernstein
33f1af6779
ZJIT: Remove idx from hir::Insn::Param (#14872)
It turns out that we don't use it anywhere.
2025-10-20 12:22:53 -04:00
Max Bernstein
fba349e658
ZJIT: Implement expandarray (#14847)
Only support the simple case: no splat or rest.

lobsters before:

<details>

```
***ZJIT: Printing ZJIT statistics on exit***
Top-20 not inlined C methods (60.5% of total 11,039,954):
                               Kernel#is_a?: 1,030,769 ( 9.3%)
                                  String#<<:   851,954 ( 7.7%)
                                   Hash#[]=:   742,941 ( 6.7%)
                              Regexp#match?:   399,894 ( 3.6%)
                              String#empty?:   353,775 ( 3.2%)
                                  Hash#key?:   349,147 ( 3.2%)
                         String#start_with?:   334,961 ( 3.0%)
                         Kernel#respond_to?:   316,528 ( 2.9%)
                 ObjectSpace::WeakKeyMap#[]:   238,978 ( 2.2%)
                              TrueClass#===:   235,771 ( 2.1%)
                             FalseClass#===:   231,144 ( 2.1%)
                             Array#include?:   211,385 ( 1.9%)
                                 Hash#fetch:   204,702 ( 1.9%)
                        Kernel#block_given?:   181,797 ( 1.6%)
                                 Kernel#dup:   179,341 ( 1.6%)
                             BasicObject#!=:   175,997 ( 1.6%)
                                  Class#new:   168,079 ( 1.5%)
                            Kernel#kind_of?:   165,600 ( 1.5%)
                                  String#==:   157,735 ( 1.4%)
                       Module#clock_gettime:   144,992 ( 1.3%)
Top-20 not annotated C methods (61.4% of total 11,202,087):
                               Kernel#is_a?: 1,212,660 (10.8%)
                                  String#<<:   851,954 ( 7.6%)
                                   Hash#[]=:   743,120 ( 6.6%)
                              Regexp#match?:   399,894 ( 3.6%)
                              String#empty?:   361,013 ( 3.2%)
                                  Hash#key?:   349,147 ( 3.1%)
                         String#start_with?:   334,961 ( 3.0%)
                         Kernel#respond_to?:   316,528 ( 2.8%)
                 ObjectSpace::WeakKeyMap#[]:   238,978 ( 2.1%)
                              TrueClass#===:   235,771 ( 2.1%)
                             FalseClass#===:   231,144 ( 2.1%)
                             Array#include?:   211,385 ( 1.9%)
                                 Hash#fetch:   204,702 ( 1.8%)
                        Kernel#block_given?:   191,666 ( 1.7%)
                                 Kernel#dup:   179,348 ( 1.6%)
                             BasicObject#!=:   176,181 ( 1.6%)
                                  Class#new:   168,079 ( 1.5%)
                            Kernel#kind_of?:   165,634 ( 1.5%)
                                  String#==:   163,667 ( 1.5%)
                       Module#clock_gettime:   144,992 ( 1.3%)
Top-2 not optimized method types for send (100.0% of total 72,318):
  cfunc: 48,055 (66.4%)
   iseq: 24,263 (33.6%)
Top-6 not optimized method types for send_without_block (100.0% of total 4,523,682):
       iseq: 2,271,936 (50.2%)
    bmethod:   985,636 (21.8%)
  optimized:   949,703 (21.0%)
      alias:   310,747 ( 6.9%)
       null:     5,106 ( 0.1%)
      cfunc:       554 ( 0.0%)
Top-13 not optimized instructions (100.0% of total 4,293,171):
             invokesuper: 2,373,404 (55.3%)
             invokeblock:   811,926 (18.9%)
             sendforward:   505,452 (11.8%)
                  opt_eq:   451,754 (10.5%)
                opt_plus:    74,404 ( 1.7%)
               opt_minus:    36,228 ( 0.8%)
  opt_send_without_block:    21,792 ( 0.5%)
                 opt_neq:     7,231 ( 0.2%)
                opt_mult:     6,752 ( 0.2%)
                  opt_or:     3,753 ( 0.1%)
                  opt_lt:       348 ( 0.0%)
                  opt_ge:        91 ( 0.0%)
                  opt_gt:        36 ( 0.0%)
Top-9 send fallback reasons (100.0% of total 25,530,724):
                send_without_block_polymorphic: 9,722,491 (38.1%)
                              send_no_profiles: 5,894,788 (23.1%)
  send_without_block_not_optimized_method_type: 4,523,682 (17.7%)
                     not_optimized_instruction: 4,293,171 (16.8%)
                send_without_block_no_profiles:   998,746 ( 3.9%)
                send_not_optimized_method_type:    72,318 ( 0.3%)
       send_without_block_cfunc_array_variadic:    15,134 ( 0.1%)
                      obj_to_string_not_string:     9,765 ( 0.0%)
       send_without_block_direct_too_many_args:       629 ( 0.0%)
Top-9 unhandled YARV insns (100.0% of total 690,950):
         expandarray: 328,490 (47.5%)
        checkkeyword: 190,694 (27.6%)
    getclassvariable:  59,901 ( 8.7%)
  invokesuperforward:  49,503 ( 7.2%)
       getblockparam:  49,119 ( 7.1%)
   opt_duparray_send:  11,978 ( 1.7%)
         getconstant:     952 ( 0.1%)
          checkmatch:     290 ( 0.0%)
                once:      23 ( 0.0%)
Top-3 compile error reasons (100.0% of total 3,718,636):
  register_spill_on_alloc: 3,418,255 (91.9%)
  register_spill_on_ccall:   182,018 ( 4.9%)
        exception_handler:   118,363 ( 3.2%)
Top-14 side exit reasons (100.0% of total 10,860,385):
                        compile_error: 3,718,636 (34.2%)
                   guard_type_failure: 2,638,926 (24.3%)
                  guard_shape_failure: 1,917,209 (17.7%)
                  unhandled_yarv_insn:   690,950 ( 6.4%)
  block_param_proxy_not_iseq_or_ifunc:   535,789 ( 4.9%)
                      unhandled_kwarg:   455,347 ( 4.2%)
                           patchpoint:   370,476 ( 3.4%)
                unknown_newarray_send:   314,786 ( 2.9%)
                      unhandled_splat:   122,071 ( 1.1%)
                   unhandled_hir_insn:    76,397 ( 0.7%)
           block_param_proxy_modified:    19,193 ( 0.2%)
               obj_to_string_fallback:       566 ( 0.0%)
               guard_type_not_failure:        22 ( 0.0%)
                            interrupt:        17 ( 0.0%)
                             send_count: 62,244,604
                     dynamic_send_count: 25,530,724 (41.0%)
                   optimized_send_count: 36,713,880 (59.0%)
              iseq_optimized_send_count: 18,587,512 (29.9%)
      inline_cfunc_optimized_send_count:  7,086,414 (11.4%)
non_variadic_cfunc_optimized_send_count:  8,375,754 (13.5%)
    variadic_cfunc_optimized_send_count:  2,664,200 ( 4.3%)
dynamic_getivar_count:                        7,365,995
dynamic_setivar_count:                        7,245,005
compiled_iseq_count:                              4,796
failed_iseq_count:                                  447
compile_time:                                     814ms
profile_time:                                       9ms
gc_time:                                            9ms
invalidation_time:                                 72ms
vm_write_pc_count:                           64,156,223
vm_write_sp_count:                           62,812,449
vm_write_locals_count:                       62,812,449
vm_write_stack_count:                        62,812,449
vm_write_to_parent_iseq_local_count:            292,458
vm_read_from_parent_iseq_local_count:         6,599,701
code_region_bytes:                           22,953,984
side_exit_count:                             10,860,385
total_insn_count:                           517,606,340
vm_insn_count:                              162,979,530
zjit_insn_count:                            354,626,810
ratio_in_zjit:                                    68.5%
```

</details>

lobsters after:

<details>

```
***ZJIT: Printing ZJIT statistics on exit***
Top-20 not inlined C methods (59.9% of total 11,291,815):
                               Kernel#is_a?: 1,046,269 ( 9.3%)
                                  String#<<:   851,954 ( 7.5%)
                                   Hash#[]=:   743,274 ( 6.6%)
                              Regexp#match?:   399,894 ( 3.5%)
                              String#empty?:   353,775 ( 3.1%)
                                  Hash#key?:   349,147 ( 3.1%)
                         String#start_with?:   334,961 ( 3.0%)
                         Kernel#respond_to?:   316,502 ( 2.8%)
                 ObjectSpace::WeakKeyMap#[]:   238,978 ( 2.1%)
                              TrueClass#===:   235,771 ( 2.1%)
                             FalseClass#===:   231,144 ( 2.0%)
                                String#sub!:   219,579 ( 1.9%)
                             Array#include?:   211,385 ( 1.9%)
                                 Hash#fetch:   204,702 ( 1.8%)
                        Kernel#block_given?:   181,797 ( 1.6%)
                                 Kernel#dup:   179,341 ( 1.6%)
                             BasicObject#!=:   175,997 ( 1.6%)
                                  Class#new:   168,079 ( 1.5%)
                            Kernel#kind_of?:   165,600 ( 1.5%)
                                  String#==:   157,742 ( 1.4%)
Top-20 not annotated C methods (60.9% of total 11,466,928):
                               Kernel#is_a?: 1,239,923 (10.8%)
                                  String#<<:   851,954 ( 7.4%)
                                   Hash#[]=:   743,453 ( 6.5%)
                              Regexp#match?:   399,894 ( 3.5%)
                              String#empty?:   361,013 ( 3.1%)
                                  Hash#key?:   349,147 ( 3.0%)
                         String#start_with?:   334,961 ( 2.9%)
                         Kernel#respond_to?:   316,502 ( 2.8%)
                 ObjectSpace::WeakKeyMap#[]:   238,978 ( 2.1%)
                              TrueClass#===:   235,771 ( 2.1%)
                             FalseClass#===:   231,144 ( 2.0%)
                                String#sub!:   219,579 ( 1.9%)
                             Array#include?:   211,385 ( 1.8%)
                                 Hash#fetch:   204,702 ( 1.8%)
                        Kernel#block_given?:   191,666 ( 1.7%)
                                 Kernel#dup:   179,348 ( 1.6%)
                             BasicObject#!=:   176,181 ( 1.5%)
                                  Class#new:   168,079 ( 1.5%)
                            Kernel#kind_of?:   165,634 ( 1.4%)
                                  String#==:   163,674 ( 1.4%)
Top-2 not optimized method types for send (100.0% of total 72,318):
  cfunc: 48,055 (66.4%)
   iseq: 24,263 (33.6%)
Top-6 not optimized method types for send_without_block (100.0% of total 4,524,016):
       iseq: 2,272,269 (50.2%)
    bmethod:   985,636 (21.8%)
  optimized:   949,704 (21.0%)
      alias:   310,747 ( 6.9%)
       null:     5,106 ( 0.1%)
      cfunc:       554 ( 0.0%)
Top-13 not optimized instructions (100.0% of total 4,294,241):
             invokesuper: 2,375,446 (55.3%)
             invokeblock:   810,955 (18.9%)
             sendforward:   505,451 (11.8%)
                  opt_eq:   451,754 (10.5%)
                opt_plus:    74,404 ( 1.7%)
               opt_minus:    36,228 ( 0.8%)
  opt_send_without_block:    21,792 ( 0.5%)
                 opt_neq:     7,231 ( 0.2%)
                opt_mult:     6,752 ( 0.2%)
                  opt_or:     3,753 ( 0.1%)
                  opt_lt:       348 ( 0.0%)
                  opt_ge:        91 ( 0.0%)
                  opt_gt:        36 ( 0.0%)
Top-9 send fallback reasons (100.0% of total 25,534,542):
                send_without_block_polymorphic: 9,723,469 (38.1%)
                              send_no_profiles: 5,896,023 (23.1%)
  send_without_block_not_optimized_method_type: 4,524,016 (17.7%)
                     not_optimized_instruction: 4,294,241 (16.8%)
                send_without_block_no_profiles:   998,947 ( 3.9%)
                send_not_optimized_method_type:    72,318 ( 0.3%)
       send_without_block_cfunc_array_variadic:    15,134 ( 0.1%)
                      obj_to_string_not_string:     9,765 ( 0.0%)
       send_without_block_direct_too_many_args:       629 ( 0.0%)
Top-8 unhandled YARV insns (100.0% of total 362,460):
        checkkeyword: 190,694 (52.6%)
    getclassvariable:  59,901 (16.5%)
  invokesuperforward:  49,503 (13.7%)
       getblockparam:  49,119 (13.6%)
   opt_duparray_send:  11,978 ( 3.3%)
         getconstant:     952 ( 0.3%)
          checkmatch:     290 ( 0.1%)
                once:      23 ( 0.0%)
Top-3 compile error reasons (100.0% of total 3,798,744):
  register_spill_on_alloc: 3,495,669 (92.0%)
  register_spill_on_ccall:   184,712 ( 4.9%)
        exception_handler:   118,363 ( 3.1%)
Top-15 side exit reasons (100.0% of total 10,637,319):
                        compile_error: 3,798,744 (35.7%)
                   guard_type_failure: 2,655,504 (25.0%)
                  guard_shape_failure: 1,917,217 (18.0%)
  block_param_proxy_not_iseq_or_ifunc:   535,789 ( 5.0%)
                      unhandled_kwarg:   455,492 ( 4.3%)
                           patchpoint:   370,478 ( 3.5%)
                  unhandled_yarv_insn:   362,460 ( 3.4%)
                unknown_newarray_send:   314,786 ( 3.0%)
                      unhandled_splat:   122,071 ( 1.1%)
                   unhandled_hir_insn:    83,066 ( 0.8%)
           block_param_proxy_modified:    19,193 ( 0.2%)
             guard_int_equals_failure:     1,914 ( 0.0%)
               obj_to_string_fallback:       566 ( 0.0%)
               guard_type_not_failure:        22 ( 0.0%)
                            interrupt:        17 ( 0.0%)
                             send_count: 62,495,067
                     dynamic_send_count: 25,534,542 (40.9%)
                   optimized_send_count: 36,960,525 (59.1%)
              iseq_optimized_send_count: 18,582,072 (29.7%)
      inline_cfunc_optimized_send_count:  7,086,638 (11.3%)
non_variadic_cfunc_optimized_send_count:  8,392,657 (13.4%)
    variadic_cfunc_optimized_send_count:  2,899,158 ( 4.6%)
dynamic_getivar_count:                        7,365,994
dynamic_setivar_count:                        7,248,500
compiled_iseq_count:                              4,780
failed_iseq_count:                                  463
compile_time:                                     816ms
profile_time:                                       9ms
gc_time:                                           11ms
invalidation_time:                                 70ms
vm_write_pc_count:                           64,363,541
vm_write_sp_count:                           63,022,221
vm_write_locals_count:                       63,022,221
vm_write_stack_count:                        63,022,221
vm_write_to_parent_iseq_local_count:            292,458
vm_read_from_parent_iseq_local_count:         6,850,977
code_region_bytes:                           23,019,520
side_exit_count:                             10,637,319
total_insn_count:                           517,303,190
vm_insn_count:                              160,562,103
zjit_insn_count:                            356,741,087
ratio_in_zjit:                                    69.0%
```

</details>

railsbench before:

<details>

```
***ZJIT: Printing ZJIT statistics on exit***
Top-20 not inlined C methods (66.1% of total 25,524,934):
                                   Hash#[]=: 1,700,237 ( 6.7%)
                             String#getbyte: 1,572,123 ( 6.2%)
                                  String#<<: 1,494,022 ( 5.9%)
                               Kernel#is_a?: 1,429,930 ( 5.6%)
                              String#empty?: 1,370,323 ( 5.4%)
                              Regexp#match?: 1,235,067 ( 4.8%)
                         Kernel#respond_to?: 1,198,251 ( 4.7%)
                                  Hash#key?: 1,087,406 ( 4.3%)
                             String#setbyte:   810,022 ( 3.2%)
                                  Integer#^:   766,624 ( 3.0%)
                        Kernel#block_given?:   603,613 ( 2.4%)
                                  String#==:   590,409 ( 2.3%)
                                  Class#new:   506,216 ( 2.0%)
                                Hash#delete:   455,288 ( 1.8%)
                             BasicObject#!=:   428,771 ( 1.7%)
                                 Hash#fetch:   408,621 ( 1.6%)
                         String#ascii_only?:   373,915 ( 1.5%)
                 ObjectSpace::WeakKeyMap#[]:   287,957 ( 1.1%)
                               NilClass#===:   277,244 ( 1.1%)
                               Kernel#Array:   269,590 ( 1.1%)
Top-20 not annotated C methods (66.8% of total 25,392,654):
                                   Hash#[]=: 1,700,416 ( 6.7%)
                             String#getbyte: 1,572,123 ( 6.2%)
                               Kernel#is_a?: 1,515,672 ( 6.0%)
                                  String#<<: 1,494,022 ( 5.9%)
                              String#empty?: 1,370,478 ( 5.4%)
                              Regexp#match?: 1,235,067 ( 4.9%)
                         Kernel#respond_to?: 1,198,251 ( 4.7%)
                                  Hash#key?: 1,087,406 ( 4.3%)
                             String#setbyte:   810,022 ( 3.2%)
                                  Integer#^:   766,624 ( 3.0%)
                        Kernel#block_given?:   603,613 ( 2.4%)
                                  String#==:   601,115 ( 2.4%)
                                  Class#new:   506,216 ( 2.0%)
                                Hash#delete:   455,288 ( 1.8%)
                             BasicObject#!=:   428,876 ( 1.7%)
                                 Hash#fetch:   408,621 ( 1.6%)
                         String#ascii_only?:   373,915 ( 1.5%)
                 ObjectSpace::WeakKeyMap#[]:   287,957 ( 1.1%)
                               NilClass#===:   277,244 ( 1.1%)
                               Kernel#Array:   269,590 ( 1.1%)
Top-2 not optimized method types for send (100.0% of total 186,159):
   iseq: 112,747 (60.6%)
  cfunc:  73,412 (39.4%)
Top-6 not optimized method types for send_without_block (100.0% of total 8,142,248):
       iseq: 3,464,671 (42.6%)
  optimized: 2,632,884 (32.3%)
    bmethod: 1,290,701 (15.9%)
      alias:   706,020 ( 8.7%)
       null:    47,942 ( 0.6%)
      cfunc:        30 ( 0.0%)
Top-11 not optimized instructions (100.0% of total 8,394,873):
             invokesuper: 5,602,274 (66.7%)
             invokeblock: 1,764,936 (21.0%)
             sendforward:   551,832 ( 6.6%)
                  opt_eq:   441,959 ( 5.3%)
                opt_plus:    31,635 ( 0.4%)
  opt_send_without_block:     1,163 ( 0.0%)
                  opt_lt:       372 ( 0.0%)
                opt_mult:       251 ( 0.0%)
                  opt_ge:       193 ( 0.0%)
                 opt_neq:       149 ( 0.0%)
                  opt_or:       109 ( 0.0%)
Top-8 send fallback reasons (100.0% of total 40,748,753):
                send_without_block_polymorphic: 12,933,923 (31.7%)
                              send_no_profiles:  9,033,636 (22.2%)
                     not_optimized_instruction:  8,394,873 (20.6%)
  send_without_block_not_optimized_method_type:  8,142,248 (20.0%)
                send_without_block_no_profiles:  1,839,228 ( 4.5%)
       send_without_block_cfunc_array_variadic:    215,046 ( 0.5%)
                send_not_optimized_method_type:    186,159 ( 0.5%)
                      obj_to_string_not_string:      3,640 ( 0.0%)
Top-9 unhandled YARV insns (100.0% of total 1,604,456):
    getclassvariable: 458,136 (28.6%)
       getblockparam: 455,921 (28.4%)
        checkkeyword: 265,425 (16.5%)
  invokesuperforward: 239,383 (14.9%)
         expandarray: 137,305 ( 8.6%)
         getconstant:  48,100 ( 3.0%)
          checkmatch:     149 ( 0.0%)
                once:      23 ( 0.0%)
   opt_duparray_send:      14 ( 0.0%)
Top-3 compile error reasons (100.0% of total 5,570,130):
  register_spill_on_alloc: 4,994,130 (89.7%)
        exception_handler:   356,784 ( 6.4%)
  register_spill_on_ccall:   219,216 ( 3.9%)
Top-13 side exit reasons (100.0% of total 12,412,181):
                        compile_error: 5,570,130 (44.9%)
                  unhandled_yarv_insn: 1,604,456 (12.9%)
                  guard_shape_failure: 1,462,872 (11.8%)
                   guard_type_failure:   845,891 ( 6.8%)
  block_param_proxy_not_iseq_or_ifunc:   765,968 ( 6.2%)
                      unhandled_kwarg:   658,341 ( 5.3%)
                           patchpoint:   504,437 ( 4.1%)
                      unhandled_splat:   446,990 ( 3.6%)
                unknown_newarray_send:   332,740 ( 2.7%)
                   unhandled_hir_insn:   160,205 ( 1.3%)
           block_param_proxy_modified:    59,589 ( 0.5%)
               obj_to_string_fallback:       553 ( 0.0%)
                            interrupt:         9 ( 0.0%)
                             send_count: 119,067,587
                     dynamic_send_count:  40,748,753 (34.2%)
                   optimized_send_count:  78,318,834 (65.8%)
              iseq_optimized_send_count:  39,936,542 (33.5%)
      inline_cfunc_optimized_send_count:  12,857,358 (10.8%)
non_variadic_cfunc_optimized_send_count:  19,722,584 (16.6%)
    variadic_cfunc_optimized_send_count:   5,802,350 ( 4.9%)
dynamic_getivar_count:                      10,980,323
dynamic_setivar_count:                      12,962,726
compiled_iseq_count:                             2,531
failed_iseq_count:                                 245
compile_time:                                    414ms
profile_time:                                     21ms
gc_time:                                          33ms
invalidation_time:                                 5ms
vm_write_pc_count:                         129,093,714
vm_write_sp_count:                         126,023,084
vm_write_locals_count:                     126,023,084
vm_write_stack_count:                      126,023,084
vm_write_to_parent_iseq_local_count:           385,461
vm_read_from_parent_iseq_local_count:       11,266,484
code_region_bytes:                          12,156,928
side_exit_count:                            12,412,181
total_insn_count:                          866,780,158
vm_insn_count:                             216,821,134
zjit_insn_count:                           649,959,024
ratio_in_zjit:                                   75.0%
```

</details>

railsbench after:

<details>

```
***ZJIT: Printing ZJIT statistics on exit***
Top-20 not inlined C methods (66.0% of total 25,597,895):
                                   Hash#[]=: 1,724,042 ( 6.7%)
                             String#getbyte: 1,572,123 ( 6.1%)
                                  String#<<: 1,494,022 ( 5.8%)
                               Kernel#is_a?: 1,429,946 ( 5.6%)
                              String#empty?: 1,370,323 ( 5.4%)
                              Regexp#match?: 1,235,067 ( 4.8%)
                         Kernel#respond_to?: 1,198,251 ( 4.7%)
                                  Hash#key?: 1,087,406 ( 4.2%)
                             String#setbyte:   810,022 ( 3.2%)
                                  Integer#^:   766,624 ( 3.0%)
                        Kernel#block_given?:   603,613 ( 2.4%)
                                  String#==:   590,699 ( 2.3%)
                                  Class#new:   506,216 ( 2.0%)
                                Hash#delete:   455,288 ( 1.8%)
                             BasicObject#!=:   428,771 ( 1.7%)
                                 Hash#fetch:   408,621 ( 1.6%)
                         String#ascii_only?:   373,915 ( 1.5%)
                 ObjectSpace::WeakKeyMap#[]:   287,957 ( 1.1%)
                               NilClass#===:   277,244 ( 1.1%)
                               Kernel#Array:   269,590 ( 1.1%)
Top-20 not annotated C methods (66.7% of total 25,465,615):
                                   Hash#[]=: 1,724,221 ( 6.8%)
                             String#getbyte: 1,572,123 ( 6.2%)
                               Kernel#is_a?: 1,515,688 ( 6.0%)
                                  String#<<: 1,494,022 ( 5.9%)
                              String#empty?: 1,370,478 ( 5.4%)
                              Regexp#match?: 1,235,067 ( 4.8%)
                         Kernel#respond_to?: 1,198,251 ( 4.7%)
                                  Hash#key?: 1,087,406 ( 4.3%)
                             String#setbyte:   810,022 ( 3.2%)
                                  Integer#^:   766,624 ( 3.0%)
                        Kernel#block_given?:   603,613 ( 2.4%)
                                  String#==:   601,405 ( 2.4%)
                                  Class#new:   506,216 ( 2.0%)
                                Hash#delete:   455,288 ( 1.8%)
                             BasicObject#!=:   428,876 ( 1.7%)
                                 Hash#fetch:   408,621 ( 1.6%)
                         String#ascii_only?:   373,915 ( 1.5%)
                 ObjectSpace::WeakKeyMap#[]:   287,957 ( 1.1%)
                               NilClass#===:   277,244 ( 1.1%)
                               Kernel#Array:   269,590 ( 1.1%)
Top-2 not optimized method types for send (100.0% of total 186,159):
   iseq: 112,747 (60.6%)
  cfunc:  73,412 (39.4%)
Top-6 not optimized method types for send_without_block (100.0% of total 8,142,248):
       iseq: 3,464,671 (42.6%)
  optimized: 2,632,884 (32.3%)
    bmethod: 1,290,701 (15.9%)
      alias:   706,020 ( 8.7%)
       null:    47,942 ( 0.6%)
      cfunc:        30 ( 0.0%)
Top-11 not optimized instructions (100.0% of total 8,442,456):
             invokesuper: 5,649,857 (66.9%)
             invokeblock: 1,764,936 (20.9%)
             sendforward:   551,832 ( 6.5%)
                  opt_eq:   441,959 ( 5.2%)
                opt_plus:    31,635 ( 0.4%)
  opt_send_without_block:     1,163 ( 0.0%)
                  opt_lt:       372 ( 0.0%)
                opt_mult:       251 ( 0.0%)
                  opt_ge:       193 ( 0.0%)
                 opt_neq:       149 ( 0.0%)
                  opt_or:       109 ( 0.0%)
Top-8 send fallback reasons (100.0% of total 40,796,314):
                send_without_block_polymorphic: 12,933,921 (31.7%)
                              send_no_profiles:  9,033,616 (22.1%)
                     not_optimized_instruction:  8,442,456 (20.7%)
  send_without_block_not_optimized_method_type:  8,142,248 (20.0%)
                send_without_block_no_profiles:  1,839,228 ( 4.5%)
       send_without_block_cfunc_array_variadic:    215,046 ( 0.5%)
                send_not_optimized_method_type:    186,159 ( 0.5%)
                      obj_to_string_not_string:      3,640 ( 0.0%)
Top-8 unhandled YARV insns (100.0% of total 1,467,151):
    getclassvariable: 458,136 (31.2%)
       getblockparam: 455,921 (31.1%)
        checkkeyword: 265,425 (18.1%)
  invokesuperforward: 239,383 (16.3%)
         getconstant:  48,100 ( 3.3%)
          checkmatch:     149 ( 0.0%)
                once:      23 ( 0.0%)
   opt_duparray_send:      14 ( 0.0%)
Top-3 compile error reasons (100.0% of total 5,825,923):
  register_spill_on_alloc: 5,225,940 (89.7%)
        exception_handler:   356,784 ( 6.1%)
  register_spill_on_ccall:   243,199 ( 4.2%)
Top-13 side exit reasons (100.0% of total 12,530,763):
                        compile_error: 5,825,923 (46.5%)
                  unhandled_yarv_insn: 1,467,151 (11.7%)
                  guard_shape_failure: 1,462,876 (11.7%)
                   guard_type_failure:   845,913 ( 6.8%)
  block_param_proxy_not_iseq_or_ifunc:   765,968 ( 6.1%)
                      unhandled_kwarg:   658,341 ( 5.3%)
                           patchpoint:   504,437 ( 4.0%)
                      unhandled_splat:   446,990 ( 3.6%)
                unknown_newarray_send:   332,740 ( 2.7%)
                   unhandled_hir_insn:   160,273 ( 1.3%)
           block_param_proxy_modified:    59,589 ( 0.5%)
               obj_to_string_fallback:       553 ( 0.0%)
                            interrupt:         9 ( 0.0%)
                             send_count: 119,163,569
                     dynamic_send_count:  40,796,314 (34.2%)
                   optimized_send_count:  78,367,255 (65.8%)
              iseq_optimized_send_count:  39,911,967 (33.5%)
      inline_cfunc_optimized_send_count:  12,857,393 (10.8%)
non_variadic_cfunc_optimized_send_count:  19,770,401 (16.6%)
    variadic_cfunc_optimized_send_count:   5,827,494 ( 4.9%)
dynamic_getivar_count:                      10,980,323
dynamic_setivar_count:                      12,986,381
compiled_iseq_count:                             2,523
failed_iseq_count:                                 252
compile_time:                                    420ms
profile_time:                                     21ms
gc_time:                                          30ms
invalidation_time:                                 4ms
vm_write_pc_count:                         128,973,665
vm_write_sp_count:                         125,926,968
vm_write_locals_count:                     125,926,968
vm_write_stack_count:                      125,926,968
vm_write_to_parent_iseq_local_count:           385,752
vm_read_from_parent_iseq_local_count:       11,267,766
code_region_bytes:                          12,189,696
side_exit_count:                            12,530,763
total_insn_count:                          866,667,490
vm_insn_count:                             217,813,201
zjit_insn_count:                           648,854,289
ratio_in_zjit:                                   74.9%
```

</details>
2025-10-20 10:55:52 -04:00
Mat Sadler
6eb75f6c36 [ruby/rubygems] update magnus version in rust extension gem template
https://github.com/ruby/rubygems/commit/1ba8eb4ab3
2025-10-20 07:04:08 +00:00
Hiroshi SHIBATA
b6f1c4edee [ruby/rubygems] Use ruby/rubygems instead of rubygems/rubygems at document, tool and configurations
https://github.com/ruby/rubygems/commit/749b498822
2025-10-20 06:52:55 +00:00
Hiroshi SHIBATA
22ceaf278f [ruby/rubygems] Now ruby/rubygems is the canonical repository url
https://github.com/ruby/rubygems/commit/c637007e91
2025-10-20 06:52:54 +00:00
viralpraxis
7587e92910 [Bug #21644] compile.c: fix newrange INSN peephole optimization for chilled string
ref: https://bugs.ruby-lang.org/issues/21644

```shell
$ ruby -v -e '("a" || "b").."c"'
ruby 3.4.7 (2025-10-08 revision 7a5688e2a2) +PRISM [x86_64-linux]
-e:1: warning: possibly useless use of .. in void context
-e:1: [BUG] Stack consistency error (sp: 7, bp: 6)
ruby 3.4.7 (2025-10-08 revision 7a5688e2a2) +PRISM [x86_64-linux]

-- Control frame information -----------------------------------------------
c:0002 p:0013 s:0007 e:000005 EVAL   -e:1 [FINISH]
c:0001 p:0000 s:0003 E:001920 DUMMY  [FINISH]

-- Ruby level backtrace information ----------------------------------------
-e:1:in '<main>'

-- Threading information ---------------------------------------------------
Total ractor count: 1
Ruby thread count for this ractor: 1

-- C level backtrace information -------------------------------------------
ruby/3.4.7/lib/libruby.so.3.4(rb_print_backtrace+0x8) [0x78aa9573c882] /tmp/ruby-build.20251010151551.31019.jR04SY/ruby-3.4.7/vm_dump.c:823
ruby/3.4.7/lib/libruby.so.3.4(rb_vm_bugreport) /tmp/ruby-build.20251010151551.31019.jR04SY/ruby-3.4.7/vm_dump.c:1155
ruby/3.4.7/lib/libruby.so.3.4(rb_bug_without_die_internal+0x6b) [0x78aa9544c62f] /tmp/ruby-build.20251010151551.31019.jR04SY/ruby-3.4.7/error.c:1097
ruby/3.4.7/lib/libruby.so.3.4(rb_bug) /tmp/ruby-build.20251010151551.31019.jR04SY/ruby-3.4.7/error.c:1115
ruby/3.4.7/lib/libruby.so.3.4(vm_stack_consistency_error+0x1f) [0x78aa9544f091] /tmp/ruby-build.20251010151551.31019.jR04SY/ruby-3.4.7/vm_insnhelper.c:6523
ruby/3.4.7/lib/libruby.so.3.4(vm_get_cref) /tmp/ruby-build.20251010151551.31019.jR04SY/ruby-3.4.7/insns.def:1134
ruby/3.4.7/lib/libruby.so.3.4(vm_setclassvariable) /tmp/ruby-build.20251010151551.31019.jR04SY/ruby-3.4.7/vm_insnhelper.c:1630
ruby/3.4.7/lib/libruby.so.3.4(vm_setclassvariable) /tmp/ruby-build.20251010151551.31019.jR04SY/ruby-3.4.7/vm_insnhelper.c:1627
ruby/3.4.7/lib/libruby.so.3.4(vm_exec_core) /tmp/ruby-build.20251010151551.31019.jR04SY/ruby-3.4.7/insns.def:253
ruby/3.4.7/lib/libruby.so.3.4(vm_exec_loop+0xa) [0x78aa95724959] /tmp/ruby-build.20251010151551.31019.jR04SY/ruby-3.4.7/vm.c:2622
ruby/3.4.7/lib/libruby.so.3.4(rb_vm_exec) /tmp/ruby-build.20251010151551.31019.jR04SY/ruby-3.4.7/vm.c:2598
ruby/3.4.7/lib/libruby.so.3.4(rb_ec_exec_node+0xa5) [0x78aa95525695] /tmp/ruby-build.20251010151551.31019.jR04SY/ruby-3.4.7/eval.c:281
ruby/3.4.7/lib/libruby.so.3.4(ruby_run_node+0x83) [0x78aa95529333] /tmp/ruby-build.20251010151551.31019.jR04SY/ruby-3.4.7/eval.c:319
ruby/3.4.7/bin/ruby(rb_main+0x21) [0x59d86f5e0186] ./main.c:43
ruby/3.4.7/bin/ruby(main) ./main.c:68
/lib/x86_64-linux-gnu/libc.so.6(__libc_start_call_main+0x7a) [0x78aa9502a1ca] ../sysdeps/nptl/libc_start_call_main.h:58
/lib/x86_64-linux-gnu/libc.so.6(call_init+0x0) [0x78aa9502a28b] ../csu/libc-start.c:360
/lib/x86_64-linux-gnu/libc.so.6(__libc_start_main_impl) ../csu/libc-start.c:347
/lib/x86_64-linux-gnu/libc.so.6(__libc_start_main) (null):0
[0x59d86f5e01d5]
```

The optimization in question:

957c832db1/compile.c\#L3453-L3480

Before entering the `newrange` optimization, the iseq looks like this:

```
== disasm: #<ISeq:<compiled>@<compiled>:1 (1,0)-(1,17)>
0000 putchilledstring                       "a"                       (   1)[Li]
0002 dup
0003 branchif                               8
0005 pop
0006 putchilledstring                       "b"
0008 putchilledstring                       "c"
0010 newrange                               0
0012 leave
```

So the optimization constructs a new range using the wrong operands (`"b"` and `"c"` instead of `"a"` and `"c"`).

I tried to fix this by checking whether the two previous instructions are labeled.
2025-10-20 14:17:36 +09:00
Daisuke Fujimura (fd0)
4353187d08 Fix extension file permissions on Cygwin in namespace feature 2025-10-20 09:38:57 +09:00
Peter Zhu
957c832db1 Fix memory leak in rb_const_remove when using namespace
We need to free the rb_const_entry_t we remove from the RCLASS_WRITABLE_CONST_TBL
otherwise it will leak memory.
2025-10-19 10:22:25 -04:00
TaoufikMejri
2f20dc5dc5 [DOC] Improve loop code example documentation 2025-10-19 20:35:57 +09:00
Hiroshi SHIBATA
8edb40f6e8
Change upstream repository of rubygems 2025-10-19 19:18:28 +09:00
Nobuyoshi Nakada
56afc0a0ce [ruby/English] [DOC] Markup variables in the full list as code
https://github.com/ruby/English/commit/5e60c1068a
2025-10-19 00:58:08 +00:00
Nobuyoshi Nakada
4e6d78b8f4 [ruby/English] [DOC] Enclose English in quotes
https://github.com/ruby/English/commit/70b46b58cc
2025-10-19 00:58:07 +00:00
Peter Zhu
ddd1aeaa64 Free loaded_features_index in namespace 2025-10-18 10:40:43 -04:00
Peter Zhu
eb4a6f0cda Fix memory leak of TypedData data in Namespace 2025-10-18 10:40:43 -04:00
Peter Zhu
d7f412e685 Add rb_root_namespace_data_type 2025-10-18 10:40:43 -04:00
Nobuyoshi Nakada
db35784895 [ruby/zlib] Initialize const member
```
  /github/workspace/src/ext/zlib/zlib.c:2608:25: warning: default initialization of an object of type 'struct read_raw_arg' with const member leaves the object uninitialized [-Wdefault-const-init-field-unsafe]
   2608 |     struct read_raw_arg ra;
        |                         ^
  /github/workspace/src/ext/zlib/zlib.c:2450:14: note: member 'argv' declared 'const' here
   2450 |         const VALUE argv[2]; /* for rb_funcallv */
        |                     ^
```

https://github.com/ruby/zlib/commit/dfa1fcbd37
2025-10-18 03:54:28 +00:00
Peter Zhu
7989a2ff46 Preallocate capacity for id table in rb_singleton_class_clone_and_attach
We know the exact capacity for the constant table created in
rb_singleton_class_clone_and_attach so we can preallocate it.
2025-10-17 20:44:04 -04:00
Burdette Lamar
9b2216954a
[DOC] Tweaks for String#rindex 2025-10-17 20:40:58 -04:00
Aiden Fox Ivey
a0bf6d3498
ZJIT: Add inlining for Kernel#respond_to? (#14873)
lobsters before:

<details>

```
***ZJIT: Printing ZJIT statistics on exit***
Top-20 not inlined C methods (61.1% of total 10,568,718):
                               Kernel#is_a?: 1,030,925 ( 9.8%)
                                  String#<<:   851,954 ( 8.1%)
                                   Hash#[]=:   742,942 ( 7.0%)
                              Regexp#match?:   399,898 ( 3.8%)
                                  Hash#key?:   349,146 ( 3.3%)
                         String#start_with?:   334,963 ( 3.2%)
                         Kernel#respond_to?:   316,528 ( 3.0%)
                 ObjectSpace::WeakKeyMap#[]:   238,978 ( 2.3%)
                              TrueClass#===:   235,771 ( 2.2%)
                             FalseClass#===:   231,144 ( 2.2%)
                             Array#include?:   211,386 ( 2.0%)
                                 Hash#fetch:   204,702 ( 1.9%)
                        Kernel#block_given?:   181,796 ( 1.7%)
                                 Kernel#dup:   179,341 ( 1.7%)
                             BasicObject#!=:   175,997 ( 1.7%)
                                 String.new:   166,696 ( 1.6%)
                            Kernel#kind_of?:   165,600 ( 1.6%)
                                  String#==:   157,746 ( 1.5%)
                      Process.clock_gettime:   144,992 ( 1.4%)
                                 Array#any?:   138,310 ( 1.3%)
Top-20 not annotated C methods (62.1% of total 10,723,613):
                               Kernel#is_a?: 1,212,816 (11.3%)
                                  String#<<:   851,954 ( 7.9%)
                                   Hash#[]=:   743,121 ( 6.9%)
                              Regexp#match?:   399,898 ( 3.7%)
                                  Hash#key?:   349,146 ( 3.3%)
                         String#start_with?:   334,963 ( 3.1%)
                         Kernel#respond_to?:   316,528 ( 3.0%)
                 ObjectSpace::WeakKeyMap#[]:   238,978 ( 2.2%)
                              TrueClass#===:   235,771 ( 2.2%)
                             FalseClass#===:   231,144 ( 2.2%)
                             Array#include?:   211,386 ( 2.0%)
                                 Hash#fetch:   204,702 ( 1.9%)
                        Kernel#block_given?:   191,665 ( 1.8%)
                                 Kernel#dup:   179,348 ( 1.7%)
                             BasicObject#!=:   176,181 ( 1.6%)
                                 String.new:   166,696 ( 1.6%)
                            Kernel#kind_of?:   165,634 ( 1.5%)
                                  String#==:   163,678 ( 1.5%)
                      Process.clock_gettime:   144,992 ( 1.4%)
                                 Array#any?:   138,310 ( 1.3%)
Top-2 not optimized method types for send (100.0% of total 72,324):
  cfunc: 48,057 (66.4%)
   iseq: 24,267 (33.6%)
Top-6 not optimized method types for send_without_block (100.0% of total 4,523,699):
       iseq: 2,271,952 (50.2%)
    bmethod:   985,636 (21.8%)
  optimized:   949,704 (21.0%)
      alias:   310,747 ( 6.9%)
       null:     5,106 ( 0.1%)
      cfunc:       554 ( 0.0%)
Top-13 not optimized instructions (100.0% of total 4,293,340):
             invokesuper: 2,373,561 (55.3%)
             invokeblock:   811,934 (18.9%)
             sendforward:   505,452 (11.8%)
                  opt_eq:   451,756 (10.5%)
                opt_plus:    74,406 ( 1.7%)
               opt_minus:    36,228 ( 0.8%)
  opt_send_without_block:    21,792 ( 0.5%)
                 opt_neq:     7,231 ( 0.2%)
                opt_mult:     6,752 ( 0.2%)
                  opt_or:     3,753 ( 0.1%)
                  opt_lt:       348 ( 0.0%)
                  opt_ge:        91 ( 0.0%)
                  opt_gt:        36 ( 0.0%)
Top-9 send fallback reasons (100.0% of total 25,481,476):
                send_without_block_polymorphic: 9,722,801 (38.2%)
                              send_no_profiles: 5,894,799 (23.1%)
  send_without_block_not_optimized_method_type: 4,523,699 (17.8%)
                     not_optimized_instruction: 4,293,340 (16.8%)
                send_without_block_no_profiles:   948,985 ( 3.7%)
                send_not_optimized_method_type:    72,324 ( 0.3%)
       send_without_block_cfunc_array_variadic:    15,134 ( 0.1%)
                      obj_to_string_not_string:     9,765 ( 0.0%)
       send_without_block_direct_too_many_args:       629 ( 0.0%)
Top-9 unhandled YARV insns (100.0% of total 690,957):
         expandarray: 328,491 (47.5%)
        checkkeyword: 190,694 (27.6%)
    getclassvariable:  59,907 ( 8.7%)
  invokesuperforward:  49,503 ( 7.2%)
       getblockparam:  49,119 ( 7.1%)
   opt_duparray_send:  11,978 ( 1.7%)
         getconstant:     952 ( 0.1%)
          checkmatch:     290 ( 0.0%)
                once:      23 ( 0.0%)
Top-3 compile error reasons (100.0% of total 3,718,841):
  register_spill_on_alloc: 3,418,472 (91.9%)
  register_spill_on_ccall:   182,023 ( 4.9%)
        exception_handler:   118,346 ( 3.2%)
Top-17 side exit reasons (100.0% of total 10,861,013):
                        compile_error: 3,718,841 (34.2%)
                   guard_type_failure: 2,638,940 (24.3%)
                  guard_shape_failure: 1,917,541 (17.7%)
                  unhandled_yarv_insn:   690,957 ( 6.4%)
  block_param_proxy_not_iseq_or_ifunc:   535,789 ( 4.9%)
                      unhandled_kwarg:   455,351 ( 4.2%)
                unknown_newarray_send:   314,786 ( 2.9%)
     patchpoint_stable_constant_names:   235,507 ( 2.2%)
                      unhandled_splat:   122,071 ( 1.1%)
        patchpoint_no_singleton_class:   109,668 ( 1.0%)
                   unhandled_hir_insn:    76,397 ( 0.7%)
          patchpoint_method_redefined:    21,598 ( 0.2%)
           block_param_proxy_modified:    19,193 ( 0.2%)
              patchpoint_no_ep_escape:     3,765 ( 0.0%)
               obj_to_string_fallback:       568 ( 0.0%)
               guard_type_not_failure:        22 ( 0.0%)
                            interrupt:        19 ( 0.0%)
                             send_count: 68,205,150
                     dynamic_send_count: 25,481,476 (37.4%)
                   optimized_send_count: 42,723,674 (62.6%)
              iseq_optimized_send_count: 18,588,101 (27.3%)
      inline_cfunc_optimized_send_count: 13,566,855 (19.9%)
non_variadic_cfunc_optimized_send_count:  7,904,518 (11.6%)
    variadic_cfunc_optimized_send_count:  2,664,200 ( 3.9%)
dynamic_getivar_count:                        7,366,650
dynamic_setivar_count:                        7,245,122
compiled_iseq_count:                              4,796
failed_iseq_count:                                  447
compile_time:                                     778ms
profile_time:                                       9ms
gc_time:                                           11ms
invalidation_time:                                 77ms
vm_write_pc_count:                           63,636,742
vm_write_sp_count:                           62,292,946
vm_write_locals_count:                       62,292,946
vm_write_stack_count:                        62,292,946
vm_write_to_parent_iseq_local_count:            292,458
vm_read_from_parent_iseq_local_count:         6,600,017
code_region_bytes:                           22,970,368
side_exit_count:                             10,861,013
total_insn_count:                           517,633,620
vm_insn_count:                              162,995,567
zjit_insn_count:                            354,638,053
ratio_in_zjit:                                    68.5%
```

</details>

lobsters after:

<details>

```
***ZJIT: Printing ZJIT statistics on exit***
Top-20 not inlined C methods (61.1% of total 10,239,008):
                               Kernel#is_a?: 1,030,914 (10.1%)
                                  String#<<:   851,954 ( 8.3%)
                                   Hash#[]=:   742,942 ( 7.3%)
                              Regexp#match?:   376,144 ( 3.7%)
                                  Hash#key?:   349,147 ( 3.4%)
                         String#start_with?:   334,963 ( 3.3%)
                 ObjectSpace::WeakKeyMap#[]:   238,978 ( 2.3%)
                              TrueClass#===:   235,771 ( 2.3%)
                             FalseClass#===:   231,144 ( 2.3%)
                             Array#include?:   211,386 ( 2.1%)
                                 Hash#fetch:   204,702 ( 2.0%)
                        Kernel#block_given?:   181,797 ( 1.8%)
                                 Kernel#dup:   179,341 ( 1.8%)
                             BasicObject#!=:   175,997 ( 1.7%)
                                 String.new:   166,696 ( 1.6%)
                            Kernel#kind_of?:   165,600 ( 1.6%)
                                  String#==:   157,751 ( 1.5%)
                      Process.clock_gettime:   144,992 ( 1.4%)
                                 Array#any?:   138,311 ( 1.4%)
                               Set#include?:   134,362 ( 1.3%)
Top-20 not annotated C methods (62.2% of total 10,372,753):
                               Kernel#is_a?: 1,212,805 (11.7%)
                                  String#<<:   851,954 ( 8.2%)
                                   Hash#[]=:   743,121 ( 7.2%)
                              Regexp#match?:   376,144 ( 3.6%)
                                  Hash#key?:   349,147 ( 3.4%)
                         String#start_with?:   334,963 ( 3.2%)
                 ObjectSpace::WeakKeyMap#[]:   238,978 ( 2.3%)
                              TrueClass#===:   235,771 ( 2.3%)
                             FalseClass#===:   231,144 ( 2.2%)
                             Array#include?:   211,386 ( 2.0%)
                                 Hash#fetch:   204,702 ( 2.0%)
                        Kernel#block_given?:   191,666 ( 1.8%)
                                 Kernel#dup:   179,348 ( 1.7%)
                             BasicObject#!=:   176,181 ( 1.7%)
                                 String.new:   166,696 ( 1.6%)
                            Kernel#kind_of?:   165,634 ( 1.6%)
                                  String#==:   163,683 ( 1.6%)
                      Process.clock_gettime:   144,992 ( 1.4%)
                                 Array#any?:   138,311 ( 1.3%)
                                Integer#<=>:   135,056 ( 1.3%)
Top-2 not optimized method types for send (100.0% of total 72,324):
  cfunc: 48,057 (66.4%)
   iseq: 24,267 (33.6%)
Top-6 not optimized method types for send_without_block (100.0% of total 4,523,699):
       iseq: 2,271,952 (50.2%)
    bmethod:   985,636 (21.8%)
  optimized:   949,704 (21.0%)
      alias:   310,747 ( 6.9%)
       null:     5,106 ( 0.1%)
      cfunc:       554 ( 0.0%)
Top-13 not optimized instructions (100.0% of total 4,293,339):
             invokesuper: 2,373,561 (55.3%)
             invokeblock:   811,933 (18.9%)
             sendforward:   505,452 (11.8%)
                  opt_eq:   451,756 (10.5%)
                opt_plus:    74,406 ( 1.7%)
               opt_minus:    36,228 ( 0.8%)
  opt_send_without_block:    21,792 ( 0.5%)
                 opt_neq:     7,231 ( 0.2%)
                opt_mult:     6,752 ( 0.2%)
                  opt_or:     3,753 ( 0.1%)
                  opt_lt:       348 ( 0.0%)
                  opt_ge:        91 ( 0.0%)
                  opt_gt:        36 ( 0.0%)
Top-9 send fallback reasons (100.0% of total 25,457,719):
                send_without_block_polymorphic: 9,699,046 (38.1%)
                              send_no_profiles: 5,894,798 (23.2%)
  send_without_block_not_optimized_method_type: 4,523,699 (17.8%)
                     not_optimized_instruction: 4,293,339 (16.9%)
                send_without_block_no_profiles:   948,985 ( 3.7%)
                send_not_optimized_method_type:    72,324 ( 0.3%)
       send_without_block_cfunc_array_variadic:    15,134 ( 0.1%)
                      obj_to_string_not_string:     9,765 ( 0.0%)
       send_without_block_direct_too_many_args:       629 ( 0.0%)
Top-9 unhandled YARV insns (100.0% of total 690,957):
         expandarray: 328,491 (47.5%)
        checkkeyword: 190,694 (27.6%)
    getclassvariable:  59,907 ( 8.7%)
  invokesuperforward:  49,503 ( 7.2%)
       getblockparam:  49,119 ( 7.1%)
   opt_duparray_send:  11,978 ( 1.7%)
         getconstant:     952 ( 0.1%)
          checkmatch:     290 ( 0.0%)
                once:      23 ( 0.0%)
Top-3 compile error reasons (100.0% of total 3,706,981):
  register_spill_on_alloc: 3,406,595 (91.9%)
  register_spill_on_ccall:   182,023 ( 4.9%)
        exception_handler:   118,363 ( 3.2%)
Top-17 side exit reasons (100.0% of total 10,837,266):
                        compile_error: 3,706,981 (34.2%)
                   guard_type_failure: 2,638,921 (24.4%)
                  guard_shape_failure: 1,917,552 (17.7%)
                  unhandled_yarv_insn:   690,957 ( 6.4%)
  block_param_proxy_not_iseq_or_ifunc:   535,789 ( 4.9%)
                      unhandled_kwarg:   455,351 ( 4.2%)
                unknown_newarray_send:   314,786 ( 2.9%)
     patchpoint_stable_constant_names:   223,630 ( 2.1%)
                      unhandled_splat:   122,071 ( 1.1%)
        patchpoint_no_singleton_class:   109,668 ( 1.0%)
                   unhandled_hir_insn:    76,397 ( 0.7%)
          patchpoint_method_redefined:    21,598 ( 0.2%)
           block_param_proxy_modified:    19,193 ( 0.2%)
              patchpoint_no_ep_escape:     3,765 ( 0.0%)
               obj_to_string_fallback:       568 ( 0.0%)
               guard_type_not_failure:        22 ( 0.0%)
                            interrupt:        17 ( 0.0%)
                             send_count: 68,157,710
                     dynamic_send_count: 25,457,719 (37.4%)
                   optimized_send_count: 42,699,991 (62.6%)
              iseq_optimized_send_count: 18,588,067 (27.3%)
      inline_cfunc_optimized_send_count: 13,872,916 (20.4%)
non_variadic_cfunc_optimized_send_count:  7,904,566 (11.6%)
    variadic_cfunc_optimized_send_count:  2,334,442 ( 3.4%)
dynamic_getivar_count:                        7,342,896
dynamic_setivar_count:                        7,245,126
compiled_iseq_count:                              4,796
failed_iseq_count:                                  447
compile_time:                                     791ms
profile_time:                                       9ms
gc_time:                                            9ms
invalidation_time:                                 68ms
vm_write_pc_count:                           63,283,243
vm_write_sp_count:                           61,939,447
vm_write_locals_count:                       61,939,447
vm_write_stack_count:                        61,939,447
vm_write_to_parent_iseq_local_count:            292,458
vm_read_from_parent_iseq_local_count:         6,576,263
code_region_bytes:                           22,872,064
side_exit_count:                             10,837,266
total_insn_count:                           517,075,555
vm_insn_count:                              162,674,783
zjit_insn_count:                            354,400,772
ratio_in_zjit:                                    68.5%
```

</details>

---------

Co-authored-by: Max Bernstein <ruby@bernsteinbear.com>
2025-10-17 22:37:22 +00:00
Peter Zhu
cb55043383 Set method table owned by iclass in rb_class_duplicate_classext
We duplicate the method table in rb_class_duplicate_classext, so we should
set RCLASSEXT_ICLASS_IS_ORIGIN and unset RCLASSEXT_ICLASS_ORIGIN_SHARED_MTBL
to signal that the iclass owns the method table and it should be freed.
2025-10-17 17:26:00 -04:00
Max Bernstein
1c119f0245 Revert "ZJIT: Mark commonly-edited files as merge=union (#14865)"
This reverts commit 23287c45806cac060ed63e87176d1a87968b9267.

This looks like a mixed bag...
2025-10-17 16:29:03 -04:00
Max Bernstein
23287c4580
ZJIT: Mark commonly-edited files as merge=union (#14865)
This helps the default merge driver make reasonable decisions (and
therefore avoid conflicts) when multiple people are e.g. adding tests
to src/hir.rs at the same time.
2025-10-17 15:48:54 -04:00
Jacob
0594646c0b
ZJIT: Don't push frame for Hash#size (#14871)
`Hash#size` was not in "Top-20 not annotated C methods" on lobsters so our before / after benchmarks are not very helpful for this change.
<details>
<summary>Before</summary>
<br>

```
***ZJIT: Printing ZJIT statistics on exit***
Top-20 not inlined C methods (60.9% of total 10,963,289):
                               Kernel#is_a?: 1,047,725 ( 9.6%)
                                  String#<<:   861,497 ( 7.9%)
                                   Hash#[]=:   740,725 ( 6.8%)
                              Regexp#match?:   398,297 ( 3.6%)
                              String#empty?:   354,809 ( 3.2%)
                                  Hash#key?:   349,173 ( 3.2%)
                         String#start_with?:   337,387 ( 3.1%)
                         Kernel#respond_to?:   321,134 ( 2.9%)
                              TrueClass#===:   239,657 ( 2.2%)
                 ObjectSpace::WeakKeyMap#[]:   238,988 ( 2.2%)
                             FalseClass#===:   234,777 ( 2.1%)
                             Array#include?:   213,229 ( 1.9%)
                        Kernel#block_given?:   181,801 ( 1.7%)
                                 Kernel#dup:   179,349 ( 1.6%)
                            Kernel#kind_of?:   174,710 ( 1.6%)
                             BasicObject#!=:   174,448 ( 1.6%)
                                 String.new:   167,716 ( 1.5%)
                                 Hash#fetch:   160,704 ( 1.5%)
                                  String#==:   158,858 ( 1.4%)
                      Process.clock_gettime:   145,002 ( 1.3%)
Top-20 not annotated C methods (61.8% of total 11,128,431):
                               Kernel#is_a?: 1,226,218 (11.0%)
                                  String#<<:   861,497 ( 7.7%)
                                   Hash#[]=:   740,904 ( 6.7%)
                              Regexp#match?:   398,297 ( 3.6%)
                              String#empty?:   362,047 ( 3.3%)
                                  Hash#key?:   349,173 ( 3.1%)
                         String#start_with?:   337,387 ( 3.0%)
                         Kernel#respond_to?:   321,134 ( 2.9%)
                              TrueClass#===:   239,657 ( 2.2%)
                 ObjectSpace::WeakKeyMap#[]:   238,988 ( 2.1%)
                             FalseClass#===:   234,777 ( 2.1%)
                             Array#include?:   213,229 ( 1.9%)
                        Kernel#block_given?:   191,670 ( 1.7%)
                                 Kernel#dup:   179,356 ( 1.6%)
                            Kernel#kind_of?:   174,745 ( 1.6%)
                             BasicObject#!=:   174,632 ( 1.6%)
                                 String.new:   167,716 ( 1.5%)
                                  String#==:   164,789 ( 1.5%)
                                 Hash#fetch:   160,704 ( 1.4%)
                      Process.clock_gettime:   145,002 ( 1.3%)
Top-2 not optimized method types for send (100.0% of total 62,854):
  cfunc: 47,647 (75.8%)
   iseq: 15,207 (24.2%)
Top-6 not optimized method types for send_without_block (100.0% of total 4,497,956):
       iseq: 2,236,049 (49.7%)
    bmethod:   993,299 (22.1%)
  optimized:   949,781 (21.1%)
      alias:   313,166 ( 7.0%)
       null:     5,106 ( 0.1%)
      cfunc:       555 ( 0.0%)
Top-13 not optimized instructions (100.0% of total 4,255,830):
             invokesuper: 2,371,027 (55.7%)
             invokeblock:   811,314 (19.1%)
             sendforward:   506,486 (11.9%)
                  opt_eq:   415,294 ( 9.8%)
                opt_plus:    77,090 ( 1.8%)
               opt_minus:    36,228 ( 0.9%)
  opt_send_without_block:    20,297 ( 0.5%)
                 opt_neq:     7,248 ( 0.2%)
                opt_mult:     6,754 ( 0.2%)
                  opt_or:     3,617 ( 0.1%)
                  opt_lt:       348 ( 0.0%)
                  opt_ge:        91 ( 0.0%)
                  opt_gt:        36 ( 0.0%)
Top-9 send fallback reasons (100.0% of total 24,945,472):
                send_without_block_polymorphic: 9,308,731 (37.3%)
                              send_no_profiles: 5,907,934 (23.7%)
  send_without_block_not_optimized_method_type: 4,497,956 (18.0%)
                     not_optimized_instruction: 4,255,830 (17.1%)
                send_without_block_no_profiles:   887,000 ( 3.6%)
                send_not_optimized_method_type:    62,854 ( 0.3%)
       send_without_block_cfunc_array_variadic:    15,138 ( 0.1%)
                      obj_to_string_not_string:     9,767 ( 0.0%)
       send_without_block_direct_too_many_args:       262 ( 0.0%)
Top-9 unhandled YARV insns (100.0% of total 707,558):
         expandarray: 347,142 (49.1%)
        checkkeyword: 190,708 (27.0%)
    getclassvariable:  59,296 ( 8.4%)
       getblockparam:  49,122 ( 6.9%)
  invokesuperforward:  48,163 ( 6.8%)
   opt_duparray_send:  11,978 ( 1.7%)
         getconstant:     840 ( 0.1%)
          checkmatch:     290 ( 0.0%)
                once:      19 ( 0.0%)
Top-2 compile error reasons (100.0% of total 3,649,990):
  register_spill_on_alloc: 3,428,507 (93.9%)
  register_spill_on_ccall:   221,483 ( 6.1%)
Top-17 side exit reasons (100.0% of total 10,833,336):
                        compile_error: 3,649,990 (33.7%)
                   guard_type_failure: 2,681,177 (24.7%)
                  guard_shape_failure: 1,897,864 (17.5%)
                  unhandled_yarv_insn:   707,558 ( 6.5%)
  block_param_proxy_not_iseq_or_ifunc:   536,761 ( 5.0%)
                      unhandled_kwarg:   456,394 ( 4.2%)
                unknown_newarray_send:   314,671 ( 2.9%)
     patchpoint_stable_constant_names:   229,825 ( 2.1%)
                      unhandled_splat:   129,577 ( 1.2%)
        patchpoint_no_singleton_class:   108,465 ( 1.0%)
                   unhandled_hir_insn:    76,401 ( 0.7%)
          patchpoint_method_redefined:    20,493 ( 0.2%)
           block_param_proxy_modified:    20,204 ( 0.2%)
              patchpoint_no_ep_escape:     3,765 ( 0.0%)
               obj_to_string_fallback:       156 ( 0.0%)
               guard_type_not_failure:        22 ( 0.0%)
                            interrupt:        13 ( 0.0%)
                             send_count: 67,968,616
                     dynamic_send_count: 24,945,472 (36.7%)
                   optimized_send_count: 43,023,144 (63.3%)
              iseq_optimized_send_count: 18,621,234 (27.4%)
      inline_cfunc_optimized_send_count: 13,438,621 (19.8%)
non_variadic_cfunc_optimized_send_count:  8,333,523 (12.3%)
    variadic_cfunc_optimized_send_count:  2,629,766 ( 3.9%)
dynamic_getivar_count:                        7,351,238
dynamic_setivar_count:                        7,267,701
compiled_iseq_count:                              4,772
failed_iseq_count:                                  465
compile_time:                                   7,006ms
profile_time:                                      52ms
gc_time:                                           46ms
invalidation_time:                                123ms
vm_write_pc_count:                           63,668,147
vm_write_sp_count:                           62,343,075
vm_write_locals_count:                       62,343,075
vm_write_stack_count:                        62,343,075
vm_write_to_parent_iseq_local_count:            292,130
vm_read_from_parent_iseq_local_count:         6,623,223
code_region_bytes:                           22,724,608
side_exit_count:                             10,833,336
total_insn_count:                           519,162,657
vm_insn_count:                              164,942,584
zjit_insn_count:                            354,220,073
ratio_in_zjit:                                    68.2%
```

</details>
<details>
<summary>After</summary>
<br>

```
***ZJIT: Printing ZJIT statistics on exit***
Top-20 not inlined C methods (61.1% of total 10,915,774):
                               Kernel#is_a?: 1,027,957 ( 9.4%)
                                  String#<<:   851,954 ( 7.8%)
                                   Hash#[]=:   740,863 ( 6.8%)
                              Regexp#match?:   398,265 ( 3.6%)
                              String#empty?:   353,775 ( 3.2%)
                                  Hash#key?:   349,161 ( 3.2%)
                         String#start_with?:   337,386 ( 3.1%)
                         Kernel#respond_to?:   316,003 ( 2.9%)
                 ObjectSpace::WeakKeyMap#[]:   238,978 ( 2.2%)
                              TrueClass#===:   235,771 ( 2.2%)
                             FalseClass#===:   231,144 ( 2.1%)
                             Array#include?:   211,340 ( 1.9%)
                                 Hash#fetch:   204,703 ( 1.9%)
                        Kernel#block_given?:   181,791 ( 1.7%)
                                 Kernel#dup:   179,337 ( 1.6%)
                             BasicObject#!=:   174,430 ( 1.6%)
                                 String.new:   166,696 ( 1.5%)
                            Kernel#kind_of?:   165,600 ( 1.5%)
                                  String#==:   154,751 ( 1.4%)
                      Process.clock_gettime:   144,992 ( 1.3%)
Top-20 not annotated C methods (62.0% of total 11,078,184):
                               Kernel#is_a?: 1,209,975 (10.9%)
                                  String#<<:   851,954 ( 7.7%)
                                   Hash#[]=:   741,042 ( 6.7%)
                              Regexp#match?:   398,265 ( 3.6%)
                              String#empty?:   361,013 ( 3.3%)
                                  Hash#key?:   349,161 ( 3.2%)
                         String#start_with?:   337,386 ( 3.0%)
                         Kernel#respond_to?:   316,003 ( 2.9%)
                 ObjectSpace::WeakKeyMap#[]:   238,978 ( 2.2%)
                              TrueClass#===:   235,771 ( 2.1%)
                             FalseClass#===:   231,144 ( 2.1%)
                             Array#include?:   211,340 ( 1.9%)
                                 Hash#fetch:   204,703 ( 1.8%)
                        Kernel#block_given?:   191,660 ( 1.7%)
                                 Kernel#dup:   179,344 ( 1.6%)
                             BasicObject#!=:   174,614 ( 1.6%)
                                 String.new:   166,696 ( 1.5%)
                            Kernel#kind_of?:   165,634 ( 1.5%)
                                  String#==:   160,682 ( 1.5%)
                      Process.clock_gettime:   144,992 ( 1.3%)
Top-2 not optimized method types for send (100.0% of total 71,084):
  cfunc: 47,638 (67.0%)
   iseq: 23,446 (33.0%)
Top-6 not optimized method types for send_without_block (100.0% of total 4,469,252):
       iseq: 2,217,500 (49.6%)
    bmethod:   985,636 (22.1%)
  optimized:   949,705 (21.2%)
      alias:   310,751 ( 7.0%)
       null:     5,106 ( 0.1%)
      cfunc:       554 ( 0.0%)
Top-13 not optimized instructions (100.0% of total 4,264,988):
             invokesuper: 2,346,307 (55.0%)
             invokeblock:   809,211 (19.0%)
             sendforward:   505,452 (11.9%)
                  opt_eq:   454,244 (10.7%)
                opt_plus:    74,059 ( 1.7%)
               opt_minus:    36,228 ( 0.8%)
  opt_send_without_block:    21,396 ( 0.5%)
                 opt_neq:     7,247 ( 0.2%)
                opt_mult:     6,752 ( 0.2%)
                  opt_or:     3,617 ( 0.1%)
                  opt_lt:       348 ( 0.0%)
                  opt_ge:        91 ( 0.0%)
                  opt_gt:        36 ( 0.0%)
Top-9 send fallback reasons (100.0% of total 25,044,791):
                send_without_block_polymorphic: 9,439,021 (37.7%)
                              send_no_profiles: 5,892,924 (23.5%)
  send_without_block_not_optimized_method_type: 4,469,252 (17.8%)
                     not_optimized_instruction: 4,264,988 (17.0%)
                send_without_block_no_profiles:   882,357 ( 3.5%)
                send_not_optimized_method_type:    71,084 ( 0.3%)
       send_without_block_cfunc_array_variadic:    15,136 ( 0.1%)
                      obj_to_string_not_string:     9,767 ( 0.0%)
       send_without_block_direct_too_many_args:       262 ( 0.0%)
Top-9 unhandled YARV insns (100.0% of total 688,760):
         expandarray: 328,369 (47.7%)
        checkkeyword: 190,697 (27.7%)
    getclassvariable:  59,286 ( 8.6%)
       getblockparam:  49,119 ( 7.1%)
  invokesuperforward:  48,162 ( 7.0%)
   opt_duparray_send:  11,978 ( 1.7%)
         getconstant:     840 ( 0.1%)
          checkmatch:     290 ( 0.0%)
                once:      19 ( 0.0%)
Top-2 compile error reasons (100.0% of total 3,642,051):
  register_spill_on_alloc: 3,420,578 (93.9%)
  register_spill_on_ccall:   221,473 ( 6.1%)
Top-17 side exit reasons (100.0% of total 10,740,844):
                        compile_error: 3,642,051 (33.9%)
                   guard_type_failure: 2,624,731 (24.4%)
                  guard_shape_failure: 1,902,123 (17.7%)
                  unhandled_yarv_insn:   688,760 ( 6.4%)
  block_param_proxy_not_iseq_or_ifunc:   534,951 ( 5.0%)
                      unhandled_kwarg:   455,354 ( 4.2%)
                unknown_newarray_send:   314,667 ( 2.9%)
     patchpoint_stable_constant_names:   227,790 ( 2.1%)
                      unhandled_splat:   121,916 ( 1.1%)
        patchpoint_no_singleton_class:   108,465 ( 1.0%)
                   unhandled_hir_insn:    76,397 ( 0.7%)
          patchpoint_method_redefined:    20,487 ( 0.2%)
           block_param_proxy_modified:    19,193 ( 0.2%)
              patchpoint_no_ep_escape:     3,765 ( 0.0%)
               obj_to_string_fallback:       156 ( 0.0%)
               guard_type_not_failure:        22 ( 0.0%)
                            interrupt:        16 ( 0.0%)
                             send_count: 67,576,368
                     dynamic_send_count: 25,044,791 (37.1%)
                   optimized_send_count: 42,531,577 (62.9%)
              iseq_optimized_send_count: 18,461,332 (27.3%)
      inline_cfunc_optimized_send_count: 13,154,471 (19.5%)
non_variadic_cfunc_optimized_send_count:  8,243,438 (12.2%)
    variadic_cfunc_optimized_send_count:  2,672,336 ( 4.0%)
dynamic_getivar_count:                        7,322,001
dynamic_setivar_count:                        7,230,445
compiled_iseq_count:                              4,771
failed_iseq_count:                                  466
compile_time:                                   7,134ms
profile_time:                                      52ms
gc_time:                                           46ms
invalidation_time:                                123ms
vm_write_pc_count:                           63,337,758
vm_write_sp_count:                           62,014,782
vm_write_locals_count:                       62,014,782
vm_write_stack_count:                        62,014,782
vm_write_to_parent_iseq_local_count:            292,458
vm_read_from_parent_iseq_local_count:         6,589,698
code_region_bytes:                           22,724,608
side_exit_count:                             10,740,844
total_insn_count:                           515,656,824
vm_insn_count:                              163,676,059
zjit_insn_count:                            351,980,765
ratio_in_zjit:                                    68.3%

```

</details>
2025-10-17 19:33:11 +00:00
Jacob
0e5cb74a00
ZJIT: Don't push frame for String#empty? (#14836)
lobsters before:

```
***ZJIT: Printing ZJIT statistics on exit***
Top-20 not inlined C methods (71.9% of total 15,247,103):
                                    Hash#[]: 4,516,006 (29.6%)
                              Class#current: 1,154,273 ( 7.6%)
                               Kernel#is_a?: 1,027,952 ( 6.7%)
                              Regexp#match?:   398,256 ( 2.6%)
                              String#empty?:   353,775 ( 2.3%)
                                  Hash#key?:   349,154 ( 2.3%)
                                   Hash#[]=:   344,347 ( 2.3%)
                         String#start_with?:   337,386 ( 2.2%)
                         Kernel#respond_to?:   316,003 ( 2.1%)
                 ObjectSpace::WeakKeyMap#[]:   238,978 ( 1.6%)
                              TrueClass#===:   235,771 ( 1.5%)
                             FalseClass#===:   231,144 ( 1.5%)
                             Array#include?:   211,339 ( 1.4%)
                                 Hash#fetch:   204,702 ( 1.3%)
                        Kernel#block_given?:   181,789 ( 1.2%)
         ActiveSupport::OrderedOptions#_get:   181,272 ( 1.2%)
                                 Kernel#dup:   179,336 ( 1.2%)
                             BasicObject#!=:   174,429 ( 1.1%)
                                  Class#new:   168,079 ( 1.1%)
                            Kernel#kind_of?:   165,600 ( 1.1%)
Top-20 not annotated C methods (72.5% of total 15,409,355):
                                    Hash#[]: 4,516,016 (29.3%)
                               Kernel#is_a?: 1,209,970 ( 7.9%)
                              Class#current: 1,154,273 ( 7.5%)
                              Regexp#match?:   398,256 ( 2.6%)
                              String#empty?:   361,013 ( 2.3%)
                                  Hash#key?:   349,154 ( 2.3%)
                                   Hash#[]=:   344,347 ( 2.2%)
                         String#start_with?:   337,386 ( 2.2%)
                         Kernel#respond_to?:   316,003 ( 2.1%)
                 ObjectSpace::WeakKeyMap#[]:   238,978 ( 1.6%)
                              TrueClass#===:   235,771 ( 1.5%)
                             FalseClass#===:   231,144 ( 1.5%)
                             Array#include?:   211,339 ( 1.4%)
                                 Hash#fetch:   204,702 ( 1.3%)
                        Kernel#block_given?:   191,658 ( 1.2%)
         ActiveSupport::OrderedOptions#_get:   181,272 ( 1.2%)
                                 Kernel#dup:   179,343 ( 1.2%)
                             BasicObject#!=:   174,613 ( 1.1%)
                                  Class#new:   168,079 ( 1.1%)
                            Kernel#kind_of?:   165,634 ( 1.1%)
Top-2 not optimized method types for send (100.0% of total 71,083):
  cfunc: 47,637 (67.0%)
   iseq: 23,446 (33.0%)
Top-6 not optimized method types for send_without_block (100.0% of total 4,482,446):
       iseq: 2,227,443 (49.7%)
    bmethod:   985,679 (22.0%)
  optimized:   952,914 (21.3%)
      alias:   310,750 ( 6.9%)
       null:     5,106 ( 0.1%)
      cfunc:       554 ( 0.0%)
Top-13 not optimized instructions (100.0% of total 4,264,922):
             invokesuper: 2,346,296 (55.0%)
             invokeblock:   809,163 (19.0%)
             sendforward:   505,446 (11.9%)
                  opt_eq:   454,244 (10.7%)
                opt_plus:    74,059 ( 1.7%)
               opt_minus:    36,227 ( 0.8%)
  opt_send_without_block:    21,396 ( 0.5%)
                 opt_neq:     7,247 ( 0.2%)
                opt_mult:     6,752 ( 0.2%)
                  opt_or:     3,617 ( 0.1%)
                  opt_lt:       348 ( 0.0%)
                  opt_ge:        91 ( 0.0%)
                  opt_gt:        36 ( 0.0%)
Top-9 send fallback reasons (100.0% of total 27,366,538):
                send_without_block_polymorphic: 9,222,828 (33.7%)
                              send_no_profiles: 5,892,897 (21.5%)
  send_without_block_not_optimized_method_type: 4,482,446 (16.4%)
                     not_optimized_instruction: 4,264,922 (15.6%)
                send_without_block_no_profiles: 3,407,046 (12.4%)
                send_not_optimized_method_type:    71,083 ( 0.3%)
       send_without_block_cfunc_array_variadic:    15,135 ( 0.1%)
                      obj_to_string_not_string:     9,919 ( 0.0%)
       send_without_block_direct_too_many_args:       262 ( 0.0%)
Top-9 unhandled YARV insns (100.0% of total 688,292):
         expandarray: 328,369 (47.7%)
        checkkeyword: 190,697 (27.7%)
    getclassvariable:  59,286 ( 8.6%)
       getblockparam:  48,651 ( 7.1%)
  invokesuperforward:  48,162 ( 7.0%)
   opt_duparray_send:  11,978 ( 1.7%)
         getconstant:     840 ( 0.1%)
          checkmatch:     290 ( 0.0%)
                once:      19 ( 0.0%)
Top-2 compile error reasons (100.0% of total 3,675,808):
  register_spill_on_alloc: 3,459,950 (94.1%)
  register_spill_on_ccall:   215,858 ( 5.9%)
Top-14 side exit reasons (100.0% of total 10,732,532):
                        compile_error: 3,675,808 (34.2%)
                   guard_type_failure: 2,616,693 (24.4%)
                  guard_shape_failure: 1,902,102 (17.7%)
                  unhandled_yarv_insn:   688,292 ( 6.4%)
  block_param_proxy_not_iseq_or_ifunc:   534,943 ( 5.0%)
                      unhandled_kwarg:   421,996 ( 3.9%)
                           patchpoint:   359,831 ( 3.4%)
                unknown_newarray_send:   314,665 ( 2.9%)
                      unhandled_splat:   121,910 ( 1.1%)
                   unhandled_hir_insn:    76,393 ( 0.7%)
           block_param_proxy_modified:    19,193 ( 0.2%)
                            interrupt:       528 ( 0.0%)
               obj_to_string_fallback:       156 ( 0.0%)
               guard_type_not_failure:        22 ( 0.0%)
                             send_count: 66,343,482
                     dynamic_send_count: 27,366,538 (41.2%)
                   optimized_send_count: 38,976,944 (58.8%)
              iseq_optimized_send_count: 17,935,768 (27.0%)
      inline_cfunc_optimized_send_count:  5,794,073 ( 8.7%)
non_variadic_cfunc_optimized_send_count: 12,588,582 (19.0%)
    variadic_cfunc_optimized_send_count:  2,658,521 ( 4.0%)
dynamic_getivar_count:                        7,321,990
dynamic_setivar_count:                        7,231,183
compiled_iseq_count:                              4,770
failed_iseq_count:                                  468
compile_time:                                   7,466ms
profile_time:                                      52ms
gc_time:                                           33ms
invalidation_time:                                116ms
vm_write_pc_count:                           64,768,186
vm_write_sp_count:                           63,445,066
vm_write_locals_count:                       63,445,066
vm_write_stack_count:                        63,445,066
vm_write_to_parent_iseq_local_count:            292,445
vm_read_from_parent_iseq_local_count:         6,461,354
code_region_bytes:                           22,446,080
side_exit_count:                             10,732,532
total_insn_count:                           515,600,654
vm_insn_count:                              163,640,874
zjit_insn_count:                            351,959,780
ratio_in_zjit:                                    68.3%
```

lobsters after:

```
***ZJIT: Printing ZJIT statistics on exit***
Top-20 not inlined C methods (72.3% of total 14,893,304):
                                    Hash#[]: 4,515,997 (30.3%)
                              Class#current: 1,154,273 ( 7.8%)
                               Kernel#is_a?: 1,027,957 ( 6.9%)
                              Regexp#match?:   398,259 ( 2.7%)
                                  Hash#key?:   349,149 ( 2.3%)
                                   Hash#[]=:   344,347 ( 2.3%)
                         String#start_with?:   337,386 ( 2.3%)
                         Kernel#respond_to?:   316,003 ( 2.1%)
                 ObjectSpace::WeakKeyMap#[]:   238,978 ( 1.6%)
                              TrueClass#===:   235,771 ( 1.6%)
                             FalseClass#===:   231,144 ( 1.6%)
                             Array#include?:   211,333 ( 1.4%)
                                 Hash#fetch:   204,703 ( 1.4%)
                        Kernel#block_given?:   181,781 ( 1.2%)
         ActiveSupport::OrderedOptions#_get:   181,272 ( 1.2%)
                                 Kernel#dup:   179,337 ( 1.2%)
                             BasicObject#!=:   174,429 ( 1.2%)
                                  Class#new:   168,079 ( 1.1%)
                            Kernel#kind_of?:   165,600 ( 1.1%)
                                  String#==:   154,751 ( 1.0%)
Top-20 not annotated C methods (72.9% of total 15,048,318):
                                    Hash#[]: 4,516,007 (30.0%)
                               Kernel#is_a?: 1,209,975 ( 8.0%)
                              Class#current: 1,154,273 ( 7.7%)
                              Regexp#match?:   398,259 ( 2.6%)
                                  Hash#key?:   349,149 ( 2.3%)
                                   Hash#[]=:   344,347 ( 2.3%)
                         String#start_with?:   337,386 ( 2.2%)
                         Kernel#respond_to?:   316,003 ( 2.1%)
                 ObjectSpace::WeakKeyMap#[]:   238,978 ( 1.6%)
                              TrueClass#===:   235,771 ( 1.6%)
                             FalseClass#===:   231,144 ( 1.5%)
                             Array#include?:   211,333 ( 1.4%)
                                 Hash#fetch:   204,703 ( 1.4%)
                        Kernel#block_given?:   191,650 ( 1.3%)
         ActiveSupport::OrderedOptions#_get:   181,272 ( 1.2%)
                                 Kernel#dup:   179,344 ( 1.2%)
                             BasicObject#!=:   174,613 ( 1.2%)
                                  Class#new:   168,079 ( 1.1%)
                            Kernel#kind_of?:   165,634 ( 1.1%)
                                  String#==:   160,682 ( 1.1%)
Top-2 not optimized method types for send (100.0% of total 71,084):
  cfunc: 47,638 (67.0%)
   iseq: 23,446 (33.0%)
Top-6 not optimized method types for send_without_block (100.0% of total 4,482,444):
       iseq: 2,227,440 (49.7%)
    bmethod:   985,679 (22.0%)
  optimized:   952,916 (21.3%)
      alias:   310,749 ( 6.9%)
       null:     5,106 ( 0.1%)
      cfunc:       554 ( 0.0%)
Top-13 not optimized instructions (100.0% of total 4,264,913):
             invokesuper: 2,346,301 (55.0%)
             invokeblock:   809,153 (19.0%)
             sendforward:   505,445 (11.9%)
                  opt_eq:   454,244 (10.7%)
                opt_plus:    74,056 ( 1.7%)
               opt_minus:    36,227 ( 0.8%)
  opt_send_without_block:    21,396 ( 0.5%)
                 opt_neq:     7,247 ( 0.2%)
                opt_mult:     6,752 ( 0.2%)
                  opt_or:     3,617 ( 0.1%)
                  opt_lt:       348 ( 0.0%)
                  opt_ge:        91 ( 0.0%)
                  opt_gt:        36 ( 0.0%)
Top-9 send fallback reasons (100.0% of total 27,366,491):
                send_without_block_polymorphic: 9,222,820 (33.7%)
                              send_no_profiles: 5,892,885 (21.5%)
  send_without_block_not_optimized_method_type: 4,482,444 (16.4%)
                     not_optimized_instruction: 4,264,913 (15.6%)
                send_without_block_no_profiles: 3,407,030 (12.4%)
                send_not_optimized_method_type:    71,084 ( 0.3%)
       send_without_block_cfunc_array_variadic:    15,134 ( 0.1%)
                      obj_to_string_not_string:     9,919 ( 0.0%)
       send_without_block_direct_too_many_args:       262 ( 0.0%)
Top-9 unhandled YARV insns (100.0% of total 688,291):
         expandarray: 328,368 (47.7%)
        checkkeyword: 190,697 (27.7%)
    getclassvariable:  59,286 ( 8.6%)
       getblockparam:  48,651 ( 7.1%)
  invokesuperforward:  48,162 ( 7.0%)
   opt_duparray_send:  11,978 ( 1.7%)
         getconstant:     840 ( 0.1%)
          checkmatch:     290 ( 0.0%)
                once:      19 ( 0.0%)
Top-2 compile error reasons (100.0% of total 3,675,807):
  register_spill_on_alloc: 3,459,949 (94.1%)
  register_spill_on_ccall:   215,858 ( 5.9%)
Top-14 side exit reasons (100.0% of total 10,732,546):
                        compile_error: 3,675,807 (34.2%)
                   guard_type_failure: 2,616,699 (24.4%)
                  guard_shape_failure: 1,902,100 (17.7%)
                  unhandled_yarv_insn:   688,291 ( 6.4%)
  block_param_proxy_not_iseq_or_ifunc:   534,950 ( 5.0%)
                      unhandled_kwarg:   421,993 ( 3.9%)
                           patchpoint:   359,837 ( 3.4%)
                unknown_newarray_send:   314,667 ( 2.9%)
                      unhandled_splat:   121,913 ( 1.1%)
                   unhandled_hir_insn:    76,393 ( 0.7%)
           block_param_proxy_modified:    19,193 ( 0.2%)
                            interrupt:       525 ( 0.0%)
               obj_to_string_fallback:       156 ( 0.0%)
               guard_type_not_failure:        22 ( 0.0%)
                             send_count: 66,343,388
                     dynamic_send_count: 27,366,491 (41.2%)
                   optimized_send_count: 38,976,897 (58.8%)
              iseq_optimized_send_count: 17,935,730 (27.0%)
      inline_cfunc_optimized_send_count:  6,147,863 ( 9.3%)
non_variadic_cfunc_optimized_send_count: 12,234,780 (18.4%)
    variadic_cfunc_optimized_send_count:  2,658,524 ( 4.0%)
dynamic_getivar_count:                        7,321,987
dynamic_setivar_count:                        7,231,160
compiled_iseq_count:                              4,770
failed_iseq_count:                                  468
compile_time:                                   7,223ms
profile_time:                                      51ms
gc_time:                                           32ms
invalidation_time:                                107ms
vm_write_pc_count:                           64,414,293
vm_write_sp_count:                           63,091,183
vm_write_locals_count:                       63,091,183
vm_write_stack_count:                        63,091,183
vm_write_to_parent_iseq_local_count:            292,443
vm_read_from_parent_iseq_local_count:         6,461,326
code_region_bytes:                           22,446,080
side_exit_count:                             10,732,546
total_insn_count:                           515,600,823
vm_insn_count:                              163,641,263
zjit_insn_count:                            351,959,560
ratio_in_zjit:                                    68.3%
```
2025-10-17 13:26:03 -04:00
Hiroshi SHIBATA
5298e97954
[rubygems/rubygems] Postpone to remove legacy mingw platform
https://github.com/rubygems/rubygems/commit/9b3a5a8ae9
2025-10-17 21:39:13 +09:00
Hiroshi SHIBATA
fb72e188ef
Update repository urls for rubygems and bundler 2025-10-17 21:26:41 +09:00
Nobuyoshi Nakada
837947ac7f Compatibility with test-unit-ruby-core 2025-10-17 18:55:54 +09:00
Jun Aruga
943b5f66f7 CI: Launchable: Fix errors at actions/setup-python on ppc64le/s390x
The following errors happened at the actions/setup-python step.

https://github.com/ruby/ruby/actions/runs/18229870239

> The version '3.x' with architecture 's390x' was not found for Ubuntu 24.04.
> The list of all available versions can be found here: https://raw.githubusercontent.com/actions/python-versions/main/versions-manifest.json

> The version '3.x' with architecture 'ppc64' was not found for Ubuntu 24.04.
> The list of all available versions can be found here: https://raw.githubusercontent.com/actions/python-versions/main/versions-manifest.json

After skipping the actions/setup-python step, the following errors also
happened at the actions/setup-java step.

https://github.com/ruby/ruby/actions/runs/18355975425?pr=14721

> make-ibm (check, ubuntu-24.04-ppc64le)
> Could not find satisfied version for SemVer '17'.

> make-ibm (check, ubuntu-24.04-s390x)
> The process '/usr/bin/bash' failed with exit code 1

> make-ibm (check, ubuntu-24.04-s390x)
> Process completed with exit code 127.

To fix the errors, I started using the Java distribution semeru (IBM Semeru
Runtime Open Edition) on the ppc64le/s390x cases.

You can see the following page for the details of the Java distribution semeru.

https://github.com/actions/setup-java?tab=readme-ov-file#supported-distributions
ead9eaa3cf/src/distributions/semeru/installer.ts (L20-L27)
2025-10-17 10:37:15 +01:00
Charlie Savage
5ced99dddb [rubygems/rubygems] :Revamp CmakeBuilder to fix the issues described in #8572. Specifically:
* Correctly pass command line arguments to CMake
* Call CMake twice - once to configure a project and a second time to build (which is the standard way to use CMake). This fixes the previously incorrect assumption that CMake generates a Make file.
* Update the tests to specify a CMake minimum version of 3.26 (which is already two years old). 3.26 is a bit arbritary but it aligns with Rice, and updates from the ancient 3.5 version being used (which CMake generates a warning message saying stop using it!)
* Update the CMake call to use CMAKE_RUNTIME_OUTPUT_DIRECTORY and CMAKE_LIBRARY_OUTPUT_DIRECTORY to tell CMake to copy compiled binaries to the a Gem's lib directory.

Note the updated builder took inspiration from the Cargo Builder, meaning you first create an instance of CmakeBuilder versus just calling class methods.

https://github.com/rubygems/rubygems/commit/9e248d4679
2025-10-17 08:24:02 +00:00
Nobuyoshi Nakada
c2860bff88
CI: Try mingw arm64 2025-10-17 15:09:16 +09:00
Nobuyoshi Nakada
87593f2c0f
Disable shorten-64-to-32 warning on IL32LLP64
Disable the shorten-64-to-32 warning for now, because it currently
generates a lot of warnings on platforms where `sizeof(void*)` is
larger than `sizeof(long)`.

TODO: Replace `long` with `ptrdiff_t` or something in the all sources.
2025-10-17 15:09:16 +09:00
Nobuyoshi Nakada
485f079dc5
win32: OBJCOPY is not needed on Windows in favor of def file 2025-10-17 15:09:15 +09:00
Nobuyoshi Nakada
1546362fd1
win32: Prefix clock_getclock and clock_getres
Get rid of conflict with inline versions provided in time.h.
2025-10-17 15:09:15 +09:00
Nobuyoshi Nakada
89961f8581
configure.ac: Update caches for functions defined in win32.c 2025-10-17 15:09:15 +09:00
Nobuyoshi Nakada
3dc620166b
win32: Install the same packages as vcpkg even on msys 2025-10-17 15:09:15 +09:00
Nobuyoshi Nakada
2dc23c1ad8
win32: Fix missing type 2025-10-17 15:08:45 +09:00
Nobuyoshi Nakada
5a23716c4f Skip low precision clocks to measure performances 2025-10-17 14:52:19 +09:00
Nobuyoshi Nakada
b2d4dc9c46 win32: Support more clockid_t
Add `CLOCK_PROCESS_CPUTIME_ID` and `CLOCK_THREAD_CPUTIME_ID`.
2025-10-17 14:52:19 +09:00
ishikawa999
ff6bd7fb4e [ruby/ipaddr] Fix InvalidAddressError message
https://github.com/ruby/ipaddr/commit/c96dbadee3
2025-10-17 05:11:36 +00:00
Hiroshi SHIBATA
9664191e19 Use ruby/setup-ruby v1.265.0 2025-10-17 10:54:32 +09:00
Aaron Patterson
4f51f6243e [rubygems/rubygems] Restrict what schemes are acceptable in the remote fetcher
The remote fetcher only works with certain schemes (`http`, `https`,
`s3`, and `file`).  It's possible for other schemes to show up in this
code and it can cause bugs.

Before this patch, doing `gem install path:///hello` would result in an
infinite loop because this function would do `send "fetch_path"`,
calling itself forever.  Now we see an exception.

I think we should validate gem names earlier, but it's really best
practice to restrict the possible strings passed to `send`.

https://github.com/rubygems/rubygems/commit/54e2781b73
2025-10-16 23:40:04 +00:00
Peter Zhu
9a80258b23 Fix crash when freeing namespaces
remove_class_from_subclasses calls st_insert, which mallocs. Malloc is not
allowed in GC. This commit replaces the st_insert with an st_update since
we know that ns_id exists in the st_table.

The following script reproduces the crash:

    require "tempfile"

    Tempfile.create do |file|
      ns = Namespace.new
      ns.require(file)
    end
2025-10-16 17:03:20 -04:00