summaryrefslogtreecommitdiff
AgeCommit message (Collapse)Author
13 min.Re-enabled repl_type_completor test with upstream fixHEADmasterHiroshi SHIBATA
https://github.com/ruby/repl_type_completor/pull/62 Notes: Merged: https://github.com/ruby/ruby/pull/13211
13 min.Use EnvUtil.apply_timeout_scale for test_io_wait.rbHiroshi SHIBATA
Notes: Merged: https://github.com/ruby/ruby/pull/13212
68 min.Update bundled gems list as of 2025-04-30git
118 min.Update default gems list at 6e7825316ed572e56f6e1baabe63ef [ci skip]git
120 min.[ruby/json] Remove explicit include of extconf.hJean Boussier
https://github.com/ruby/json/commit/6b059900de .
120 min.[ruby/json] Fix --with-static-linked-ext buildsJean Boussier
https://github.com/ruby/json/commit/d7d60cccb0
120 min.[ruby/json] Fix i686 buildsJean Boussier
We should test compilation with `-msse2` because we need to test with whatever arguments Ruby will be compiled with. https://github.com/ruby/json/commit/0a871365db
120 min.[ruby/json] SIMD: Match control char and double quote in one passJean Boussier
`c < 32 || c == 34` is equivalent to `c ^ 2 < 33`. Found in: https://lemire.me/blog/2025/04/13/detect-control-characters-quotes-and-backslashes-efficiently-using-swar/ The gain seem mostly present on micro-benchmark, and even there aren't very consistent, but it's never slower. ``` == Encoding long string (124001 bytes) ruby 3.4.2 (2025-02-15 revision https://github.com/ruby/json/commit/d2930f8e7a) +YJIT +PRISM [arm64-darwin24] Warming up -------------------------------------- after 5.295k i/100ms Calculating ------------------------------------- after 55.796k (± 3.4%) i/s (17.92 μs/i) - 280.635k in 5.035690s Comparison: before: 49840.7 i/s after: 55795.8 i/s - 1.12x faster ``` https://github.com/ruby/json/commit/034c5debd8
120 min.Update ext/json/generator/dependJean Boussier
120 min.[ruby/json] Introduce ARM Neon and SSE2 SIMD.Scott Myron
(https://github.com/ruby/json/pull/743) See the pull request for the long development history: https://github.com/ruby/json/pull/743 ``` == Encoding activitypub.json (52595 bytes) ruby 3.4.2 (2025-02-15 revision https://github.com/ruby/json/commit/d2930f8e7a) +YJIT +PRISM [arm64-darwin24] Warming up -------------------------------------- after 2.913k i/100ms Calculating ------------------------------------- after 29.377k (± 2.0%) i/s (34.04 μs/i) - 148.563k in 5.059169s Comparison: before: 23314.1 i/s after: 29377.3 i/s - 1.26x faster == Encoding citm_catalog.json (500298 bytes) ruby 3.4.2 (2025-02-15 revision https://github.com/ruby/json/commit/d2930f8e7a) +YJIT +PRISM [arm64-darwin24] Warming up -------------------------------------- after 152.000 i/100ms Calculating ------------------------------------- after 1.569k (± 0.8%) i/s (637.49 μs/i) - 7.904k in 5.039001s Comparison: before: 1485.6 i/s after: 1568.7 i/s - 1.06x faster == Encoding twitter.json (466906 bytes) ruby 3.4.2 (2025-02-15 revision https://github.com/ruby/json/commit/d2930f8e7a) +YJIT +PRISM [arm64-darwin24] Warming up -------------------------------------- after 309.000 i/100ms Calculating ------------------------------------- after 3.115k (± 3.1%) i/s (321.01 μs/i) - 15.759k in 5.063776s Comparison: before: 2508.3 i/s after: 3115.2 i/s - 1.24x faster ``` https://github.com/ruby/json/commit/49003523da
120 min.[ruby/json] Use RB_TYPE_PJean Boussier
https://github.com/ruby/json/commit/b14250f1da
120 min.[ruby/json] Handle non-string keys returning immediate values via `to_s`Jean Boussier
We can't directly call `RBASIC_CLASS` as the return value of `to_s` may be an immediate. https://github.com/ruby/json/commit/12dc394d11
120 min.[ruby/json] Release 2.11.3Jean Boussier
https://github.com/ruby/json/commit/3e025f76d7
120 min.[ruby/json] Stop caching the generator state pointerJean Boussier
Fix: https://github.com/ruby/json/issues/790 If we end up calling something that spills the state on the heap, the pointer we received is outdated and may be out of sync. https://github.com/ruby/json/commit/2ffa4ea46b
2 hoursImprove syntax style consistency in shape.c and shape.hJean Boussier
Most of this code use the `type * name` style, while the overwhemling majority of the rest of ruby use the `type *name` style. This is a cosmetic change, but helps with readability.
2 hoursRUBY_T_{TRUE,FALSE} comments were reversedMatt Valentine-House
[ci skip] Notes: Merged: https://github.com/ruby/ruby/pull/13207
4 hoursAdded GCC 15 buildHiroshi SHIBATA
Notes: Merged: https://github.com/ruby/ruby/pull/13210
9 hoursUpdate auto_request_review config for YJIT/ZJIT (#13209)Takashi Kokubun
Notes: Merged-By: k0kubun <takashikkbn@gmail.com>
11 hoursst.c: Removed unused `set_add_direct_with_hash` functionJean Boussier
Notes: Merged: https://github.com/ruby/ruby/pull/13208
12 hourstest/ruby/test_set.rb: mmtk doesn't have GC.compactJean Boussier
12 hoursopt_new needs to happen after safe navigationAaron Patterson
If safe navigation instructions happen first, we get a stack inconsistency error. Notes: Merged: https://github.com/ruby/ruby/pull/13205
12 hoursDon't call hash tombstone compaction from GC compactionAaron Patterson
Tombstone removal may possibly require allocation, and we're not allowed to allocate during GC. This commit also renames `set_compact` to `set_update_references` to differentiate tombstone removal compaction with GC object compaction. Co-Authored-By: Max Bernstein <max.bernstein@shopify.com> Co-authored-by: Jean Boussier <jean.boussier@gmail.com> Notes: Merged: https://github.com/ruby/ruby/pull/13206
14 hoursExplain a missing USE_ZJIT check on rb_vm_max_insn_name_sizeTakashi Kokubun
14 hoursZJIT: Disable ZJIT instructions when USE_ZJIT is 0 (#13199)Takashi Kokubun
* ZJIT: Disable ZJIT instructions when USE_ZJIT is 0 * Test the order of ZJIT instructions * Add more jobs that disable JITs * Show instruction names in the message Notes: Merged-By: k0kubun <takashikkbn@gmail.com>
14 hoursMake sure to call find() on basic block argumentsMax Bernstein
This ensures basic block arguments keep instructions alive, etc. Notes: Merged: https://github.com/ruby/ruby/pull/13204
14 hoursDefault instruction output type to AnyMax Bernstein
If we're adding a bunch of instructions in the middle of an optimization pass, we don't want to use their (currently uninitialized) types because they start as Empty, and Empty is a subtype of everything. This breaks some optimizations. This Any will get refined the next time we call infer_types. Notes: Merged: https://github.com/ruby/ruby/pull/13204
15 hoursZJIT: Handle ZJIT options properly (#13197)Takashi Kokubun
Notes: Merged-By: k0kubun <takashikkbn@gmail.com>
16 hoursAdd testsMax Bernstein
Notes: Merged: https://github.com/ruby/ruby/pull/13198
16 hoursDon't support blockarg in opt_newMax Bernstein
We don't calculate the correct argc so the bookkeeping slot is something else (unexpected) instead of Qnil (expected). Notes: Merged: https://github.com/ruby/ruby/pull/13198
37 hoursZJIT: Replace GetConstantPath with Const if the IC is not empty (#13183)Max Bernstein
* Add rb_zjit_constcache_shareable * Add rb_zjit_multi_ractor_p * Replace GetConstantPath with Const if the IC is not empty Notes: Merged-By: k0kubun <takashikkbn@gmail.com>
37 hoursZJIT: Drop a duplicated call into optimize (#13196)Takashi Kokubun
* ZJIT: Drop a duplicated call into optimize * Update a comment Co-authored-by: Max Bernstein <tekknolagi@gmail.com> --------- Co-authored-by: Max Bernstein <tekknolagi@gmail.com> Notes: Merged-By: k0kubun <takashikkbn@gmail.com>
37 hoursAdd comments for cryptic functions in iseq.cTakashi Kokubun
40 hoursZJIT: Drop trace_zjit_* instructions (#13189)Takashi Kokubun
Notes: Merged-By: k0kubun <takashikkbn@gmail.com>
41 hoursSupport Marshal.{dump,load} for core SetJeremy Evans
This was missed when adding core Set, because it's handled implicitly for T_OBJECT. Keep marshal compatibility between core Set and stdlib Set, so you can unmarshal core Set with stdlib Set and vice versa. Co-authored-by: Nobuyoshi Nakada <nobu@ruby-lang.org> Notes: Merged: https://github.com/ruby/ruby/pull/13185 Merged-By: jeremyevans <code@jeremyevans.net>
43 hoursYJIT: Fix potential infinite loop when OOM (GH-13186)Rian McGuire
Avoid generating an infinite loop in the case where: 1. Block `first` is adjacent to block `second`, and the branch from `first` to `second` is a fallthrough, and 2. Block `second` immediately exits to the interpreter, and 3. Block `second` is invalidated and YJIT is OOM While pondering how to fix this, I think I've stumbled on another related edge case: 1. Block `incoming_one` and `incoming_two` both branch to block `second`. Block `incoming_one` has a fallthrough 2. Block `second` immediately exits to the interpreter (so it starts with its exit) 3. When Block `second` is invalidated, the incoming fallthrough branch from `incoming_one` might be rewritten first, which overwrites the start of block `second` with a jump to a new branch stub. 4. YJIT runs of out memory 5. The incoming branch from `incoming_two` is then rewritten, but because we're OOM we can't generate a new stub, so we use `second`'s exit as the branch target. However `second`'s exit was already overwritten with a jump to the branch stub for `incoming_one`, so `incoming_two` will end up jumping to `incoming_one`'s branch stub. Fixes [Bug #21257] Notes: Merged: https://github.com/ruby/ruby/pull/13186 Merged-By: XrXr
45 hoursSuppress error message when gc is cleaned already [ci skip]Nobuyoshi Nakada
2 daysFix nondeterministic failure in test_latest_gc_info_weak_references_countJeremy Evans
Clear the ary variable before setting it to nil. Otherwise, if the previous ary value was somewhere on the stack, all references in it would be considered live, and the wmap size would be 10000.
3 daysUse a `set_table` for `rb_vm_struct.unused_block_warning_table`Jean Boussier
Now that we have a hash-set implementation we can use that instead of a hash-table with a static value.
3 daysFree jump buffers leaked by `cont_restore_thread` in WASI builds刘皓
Notes: Merged: https://github.com/ruby/ruby/pull/13142
3 daysFix jump buffer leak in WASI builds刘皓
Notes: Merged: https://github.com/ruby/ruby/pull/13142
4 days[ruby/ipaddr] Added IPAddr#+/-Taketo Takashima
https://github.com/ruby/ipaddr/commit/78b4f53bf5
4 daysUse `set_table` to track const cachesJean Boussier
Now that we have a `set_table` implementation, we can use it to track const caches and save some memory. We could even save some more memory if `numtable` didn't store a copy of the `hash` and instead recomputed it every time, but this is a quick win. Notes: Merged: https://github.com/ruby/ruby/pull/13184
4 daysImplement Set as a core classJeremy Evans
Set has been an autoloaded standard library since Ruby 3.2. The standard library Set is less efficient than it could be, as it uses Hash for storage, which stores unnecessary values for each key. Implementation details: * Core Set uses a modified version of `st_table`, named `set_table`. than `s/st_/set_/`, the main difference is that the stored records do not have values, making them 1/3 smaller. `st_table_entry` stores `hash`, `key`, and `record` (value), while `set_table_entry` only stores `hash` and `key`. This results in large sets using ~33% less memory compared to stdlib Set. For small sets, core Set uses 12% more memory (160 byte object slot and 64 malloc bytes, while stdlib set uses 40 for Set and 160 for Hash). More memory is used because the set_table is embedded and 72 bytes in the object slot are currently wasted. Hopefully we can make this more efficient and have it stored in an 80 byte object slot in the future. * All methods are implemented as cfuncs, except the pretty_print methods, which were moved to `lib/pp.rb` (which is where the pretty_print methods for other core classes are defined). As is typical for core classes, internal calls call C functions and not Ruby methods. For example, to check if something is a Set, `rb_obj_is_kind_of` is used, instead of calling `is_a?(Set)` on the related object. * Almost all methods use the same algorithm that the pure-Ruby implementation used. The exception is when calling `Set#divide` with a block with 2-arity. The pure-Ruby method used tsort to implement this. I developed an algorithm that only allocates a single intermediate hash and does not need tsort. * The `flatten_merge` protected method is no longer necessary, so it is not implemented (it could be). * Similar to Hash/Array, subclasses of Set are no longer reflected in `inspect` output. * RDoc from stdlib Set was moved to core Set, with minor updates. This includes a comprehensive benchmark suite for all public Set methods. As you would expect, the native version is faster in the vast majority of cases, and multiple times faster in many cases. There are a few cases where it is significantly slower: * Set.new with no arguments (~1.6x) * Set#compare_by_identity for small sets (~1.3x) * Set#clone for small sets (~1.5x) * Set#dup for small sets (~1.7x) These are slower as Set does not currently use the AR table optimization that Hash does, so a new set_table is initialized for each call. I'm not sure it's worth the complexity to have an AR table-like optimization for small sets (for hashes it makes sense, as small hashes are used everywhere in Ruby). The rbs and repl_type_completor bundled gems will need updates to support core Set. The pull request marks them as allowed failures. This passes all set tests with no changes. The following specs needed modification: * Modifying frozen set error message (changed for the better) * `Set#divide` when passed a 2-arity block no longer yields the same object as both the first and second argument (this seems like an issue with the previous implementation). * Set-like objects that override `is_a?` such that `is_a?(Set)` return `true` are no longer treated as Set instances. * `Set.allocate.hash` is no longer the same as `nil.hash` * `Set#join` no longer calls `Set#to_a` (it calls the underlying C function). * `Set#flatten_merge` protected method is not implemented. Previously, `set.rb` added a `SortedSet` autoload, which loads `set/sorted_set.rb`. This replaces the `Set` autoload in `prelude.rb` with a `SortedSet` autoload, but I recommend removing it and `set/sorted_set.rb`. This moves `test/set/test_set.rb` to `test/ruby/test_set.rb`, reflecting that switch to a core class. This does not move the spec files, as I'm not sure how they should be handled. Internally, this uses the st_* types and functions as much as possible, and only adds set_* types and functions as needed. The underlying set_table implementation is stored in st.c, but there is no public C-API for it, nor is there one planned, in order to keep the ability to change the internals going forward. For internal uses of st_table with Qtrue values, those can probably be replaced with set_table. To do that, include internal/set_table.h. To handle symbol visibility (rb_ prefix), internal/set_table.h uses the same macro approach that include/ruby/st.h uses. The Set class (rb_cSet) and all methods are defined in set.c. There isn't currently a C-API for the Set class, though C-API functions can be added as needed going forward. Implements [Feature #21216] Co-authored-by: Jean Boussier <jean.boussier@gmail.com> Co-authored-by: Oliver Nutter <mrnoname1000@riseup.net>
4 daysmaybe fix bindgenAaron Patterson
4 daysDeopt if iseq trace events are enabledAaron Patterson
4 daysAdd parse.y implementationAaron Patterson
4 daysupdate allocation location testsAaron Patterson
4 daysInline Class#new.Aaron Patterson
This commit inlines instructions for Class#new. To make this work, we added a new YARV instructions, `opt_new`. `opt_new` checks whether or not the `new` method is the default allocator method. If it is, it allocates the object, and pushes the instance on the stack. If not, the instruction jumps to the "slow path" method call instructions. Old instructions: ``` > ruby --dump=insns -e'Object.new' == disasm: #<ISeq:<main>@-e:1 (1,0)-(1,10)> 0000 opt_getconstant_path <ic:0 Object> ( 1)[Li] 0002 opt_send_without_block <calldata!mid:new, argc:0, ARGS_SIMPLE> 0004 leave ``` New instructions: ``` > ./miniruby --dump=insns -e'Object.new' == disasm: #<ISeq:<main>@-e:1 (1,0)-(1,10)> 0000 opt_getconstant_path <ic:0 Object> ( 1)[Li] 0002 putnil 0003 swap 0004 opt_new <calldata!mid:new, argc:0, ARGS_SIMPLE>, 11 0007 opt_send_without_block <calldata!mid:initialize, argc:0, FCALL|ARGS_SIMPLE> 0009 jump 14 0011 opt_send_without_block <calldata!mid:new, argc:0, ARGS_SIMPLE> 0013 swap 0014 pop 0015 leave ``` This commit speeds up basic object allocation (`Foo.new`) by 60%, but classes that take keyword parameters see an even bigger benefit because no hash is allocated when instantiating the object (3x to 6x faster). Here is an example that uses `Hash.new(capacity: 0)`: ``` > hyperfine "ruby --disable-gems -e'i = 0; while i < 10_000_000; Hash.new(capacity: 0); i += 1; end'" "./ruby --disable-gems -e'i = 0; while i < 10_000_000; Hash.new(capacity: 0); i += 1; end'" Benchmark 1: ruby --disable-gems -e'i = 0; while i < 10_000_000; Hash.new(capacity: 0); i += 1; end' Time (mean ± σ): 1.082 s ± 0.004 s [User: 1.074 s, System: 0.008 s] Range (min … max): 1.076 s … 1.088 s 10 runs Benchmark 2: ./ruby --disable-gems -e'i = 0; while i < 10_000_000; Hash.new(capacity: 0); i += 1; end' Time (mean ± σ): 627.9 ms ± 3.5 ms [User: 622.7 ms, System: 4.8 ms] Range (min … max): 622.7 ms … 633.2 ms 10 runs Summary ./ruby --disable-gems -e'i = 0; while i < 10_000_000; Hash.new(capacity: 0); i += 1; end' ran 1.72 ± 0.01 times faster than ruby --disable-gems -e'i = 0; while i < 10_000_000; Hash.new(capacity: 0); i += 1; end' ``` This commit changes the backtrace for `initialize`: ``` aaron@tc ~/g/ruby (inline-new)> cat test.rb class Foo def initialize puts caller end end def hello Foo.new end hello aaron@tc ~/g/ruby (inline-new)> ruby -v test.rb ruby 3.4.2 (2025-02-15 revision d2930f8e7a) +PRISM [arm64-darwin24] test.rb:8:in 'Class#new' test.rb:8:in 'Object#hello' test.rb:11:in '<main>' aaron@tc ~/g/ruby (inline-new)> ./miniruby -v test.rb ruby 3.5.0dev (2025-03-28T23:59:40Z inline-new c4157884e4) +PRISM [arm64-darwin24] test.rb:8:in 'Object#hello' test.rb:11:in '<main>' ``` It also increases memory usage for calls to `new` by 122 bytes: ``` aaron@tc ~/g/ruby (inline-new)> cat test.rb require "objspace" class Foo def initialize puts caller end end def hello Foo.new end puts ObjectSpace.memsize_of(RubyVM::InstructionSequence.of(method(:hello))) aaron@tc ~/g/ruby (inline-new)> make runruby RUBY_ON_BUG='gdb -x ./.gdbinit -p' ./miniruby -I./lib -I. -I.ext/common ./tool/runruby.rb --extout=.ext -- --disable-gems ./test.rb 656 aaron@tc ~/g/ruby (inline-new)> ruby -v test.rb ruby 3.4.2 (2025-02-15 revision d2930f8e7a) +PRISM [arm64-darwin24] 544 ``` Thanks to @ko1 for coming up with this idea! Co-Authored-By: John Hawthorn <john@hawthorn.email>
5 daysZJIT: Bail out of HIR translation if we can't handle a send flag (#13182)Max Bernstein
Bail out of HIR translation if we can't handle a send flag Notes: Merged-By: k0kubun <takashikkbn@gmail.com>
5 daysZJIT: Emit CCall if we know the type statically, not just from profiles (#13173)Max Bernstein
Emit CCall if we know the type statically, not just from profiles Notes: Merged-By: k0kubun <takashikkbn@gmail.com>
close