summaryrefslogtreecommitdiff
path: root/test
AgeCommit message (Collapse)Author
9 hourstest/ruby/test_set.rb: mmtk doesn't have GC.compactJean Boussier
9 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
9 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 <[email protected]> Co-authored-by: Jean Boussier <[email protected]> Notes: Merged: https://github.com/ruby/ruby/pull/13206
11 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 <[email protected]>
13 hoursAdd testsMax Bernstein
Notes: Merged: https://github.com/ruby/ruby/pull/13198
38 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 <[email protected]> Notes: Merged: https://github.com/ruby/ruby/pull/13185 Merged-By: jeremyevans <[email protected]>
47 hoursFix 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.
4 days[ruby/ipaddr] Added IPAddr#+/-Taketo Takashima
https://github.com/ruby/ipaddr/commit/78b4f53bf5
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 <[email protected]> Co-authored-by: Oliver Nutter <[email protected]>
4 daysDeopt if iseq trace events are enabledAaron 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 <[email protected]>
6 daysFix a flaky test by making sure that a test thread stopsYusuke Endoh
``` 1) Failure: TestThread#test_join_argument_conversion [D:/a/ruby/ruby/src/test/ruby/test_thread.rb:249]: Expected nil (oid=4) to be the same as #<TestThread::Thread:0x000001e9e13bbc18 D:/a/ruby/ruby/src/test/ruby/test_thread.rb:245 run> (oid=3856). ``` https://github.com/ruby/ruby/actions/runs/14636019219/job/41067199813?pr=13169 Notes: Merged: https://github.com/ruby/ruby/pull/13170
6 daysobjspace_dump: Include `shareable` flagJean Boussier
Given that the currently planned ractor local GC implementation performance will heavilly be influenced by the number of shareable objects it would be valuable to be able to know how many of them are in the heap.
7 daysIncrease fiber sleep test tolerance. (#13152)Samuel Williams
Notes: Merged-By: ioquatix <[email protected]>
10 days[ruby/openssl] asn1: check for missing EOC in indefinite length encodingKazuki Yamaguchi
EOC octets are required at the end of contents of a constructed encoding that uses the indefinite length form. This cannot be assumed from the end of the input. Raise an exception when necessary. https://github.com/ruby/openssl/commit/bc20c13a7c
12 daysAdd codegen for NewArray instruction (https://github.com/Shopify/zjit/pull/110)Aiden Fox Ivey
* Show failing test * Add second test case * Add empty NewArray setup * Update opt_tests and fix NewArray instantiation * Add code generation for NewArray * Add NewArray ordering test Notes: Merged: https://github.com/ruby/ruby/pull/13131
12 daysImplement JIT-to-JIT calls (https://github.com/Shopify/zjit/pull/109)Takashi Kokubun
* Implement JIT-to-JIT calls * Use a closer dummy address for Arm64 * Revert an obsoleted change * Revert a few more obsoleted changes * Fix outdated comments * Explain PosMarkers for CCall * s/JIT code/machine code/ * Get rid of ParallelMov Notes: Merged: https://github.com/ruby/ruby/pull/13131
12 daysAdd codegen support for ArrayDupAiden Fox Ivey
Notes: Merged: https://github.com/ruby/ruby/pull/13131
12 daysStrength reduce to `CCall` for sends landing in simple C methodsAlan Wu
A new optimization pass. Also: - Printing for `Insn::CCall` - Wrap `ID` and add convenience method for printing, replacing calls to rb_id2name() Notes: Merged: https://github.com/ruby/ruby/pull/13131
12 daysSplit LHS of CMP if it's an immediate (https://github.com/Shopify/zjit/pull/94)Takashi Kokubun
Notes: Merged: https://github.com/ruby/ruby/pull/13131
12 daysFix opt_neq HIR codegenMax Bernstein
Notes: Merged: https://github.com/ruby/ruby/pull/13131
12 daysCompile Param into VReg and ParallelMov ↵Takashi Kokubun
(https://github.com/Shopify/zjit/pull/87) Notes: Merged: https://github.com/ruby/ruby/pull/13131
12 daysAdd recursive factorial and fibonacci functions to test_zjit.rbMaxime Chevalier-Boisvert
Notes: Merged: https://github.com/ruby/ruby/pull/13131
12 daysCompile IfFalse, IfTrue, and Jump instructions ↵Takashi Kokubun
(https://github.com/Shopify/zjit/pull/72) * Compile IfFalse instruction * Add a TODO comment * Rename *s_len to num_*s * Run only gen_param() against block.params * Add a few more tests * Wrap label indexes with Label * Compile blocks in reverse post-order * Simplify a nested test * s/get_block/block/ * Return a number instead of an iterator * Clarify the allocator uses disjoint sets of registers * Use Display for Block and Insn * Compile IfTrue and Jump * Avoid resolving Param instructions * Always compile Insn::Param as basic block arguments * Remove an obsoleted variable * Change it back to use find * Use find for params too * Use Display more * Add more tests * nested if * if after if * if elsif else * loop after loop * nested loops * if in loop * loop in if Notes: Merged: https://github.com/ruby/ruby/pull/13131
12 daysImplement dynamic dispatch for opt_send_without_block ↵Takashi Kokubun
(https://github.com/Shopify/zjit/pull/63) * Implement dynamic dispatch for opt_send_without_block * Rename stack methods * Fix typos * More clarification on gen_save_sp() * Update a comment * Update a comment about spills * Rename name to method_name * Test no-arg and 2-arg method calls Notes: Merged: https://github.com/ruby/ruby/pull/13131
12 daysImplement codegen for Test insn (https://github.com/Shopify/zjit/pull/57)Maxime Chevalier-Boisvert
* Implement codegen for Test insn * Update zjit/src/codegen.rs Co-authored-by: Alan Wu <[email protected]> --------- Co-authored-by: Alan Wu <[email protected]> Notes: Merged: https://github.com/ruby/ruby/pull/13131
12 daysReorder two tests, update commentMaxime Chevalier-Boisvert
Notes: Merged: https://github.com/ruby/ruby/pull/13131
12 daysAdd a skipped test case for opt_mult overflowTakashi Kokubun
Notes: Merged: https://github.com/ruby/ruby/pull/13131
12 daysImplement all basic Fixnum instructions ↵Takashi Kokubun
(https://github.com/Shopify/zjit/pull/50) * Implement all basic Fixnum instructions * Use opnd! macro for other instructions as well Notes: Merged: https://github.com/ruby/ruby/pull/13131
12 daysCompile FixnumLt (https://github.com/Shopify/zjit/pull/48)Max Bernstein
Notes: Merged: https://github.com/ruby/ruby/pull/13131
12 daysAdd comments to testsMaxime Chevalier-Boisvert
Notes: Merged: https://github.com/ruby/ruby/pull/13131
12 daysAdd commented out if-else test to test_zjit.rbMaxime Chevalier-Boisvert
Notes: Merged: https://github.com/ruby/ruby/pull/13131
12 daysAdd while loop test to test_zjit.rbMaxime Chevalier-Boisvert
Notes: Merged: https://github.com/ruby/ruby/pull/13131
12 daysAdd small test for setlocalMaxime Chevalier-Boisvert
Notes: Merged: https://github.com/ruby/ruby/pull/13131
12 daysSet a return value before popping registers ↵Takashi Kokubun
(https://github.com/Shopify/zjit/pull/41) Notes: Merged: https://github.com/ruby/ruby/pull/13131
12 daysImplement Insn::FixnumSub (https://github.com/Shopify/zjit/pull/42)Takashi Kokubun
Notes: Merged: https://github.com/ruby/ruby/pull/13131
12 daysPass test results using #inspectTakashi Kokubun
Notes: Merged: https://github.com/ruby/ruby/pull/13131
12 daysAssert everything is compiled in test_zjit ↵Takashi Kokubun
(https://github.com/Shopify/zjit/pull/40) * Assert everything is compiled in test_zjit * Update a comment on rb_zjit_assert_compiles Co-authored-by: Maxime Chevalier-Boisvert <[email protected]> * Add a comment about assert_compiles * Actually use pipe_fd --------- Co-authored-by: Maxime Chevalier-Boisvert <[email protected]> Notes: Merged: https://github.com/ruby/ruby/pull/13131
12 days[Feature #20724] Bump Unicode version to 16.0.0Mari Imaizumi
Notes: Merged: https://github.com/ruby/ruby/pull/13117
13 daysOnly test on known good platforms. (#13123)Samuel Williams
Notes: Merged-By: ioquatix <[email protected]>
13 daysPrefer `th->ec` for stack base/size. (#13101)Samuel Williams
Notes: Merged-By: ioquatix <[email protected]>
14 days[ruby/openssl] ssl: fix SSLSocket#syswrite with String-convertible objectsKazuki Yamaguchi
Correctly pass the new object assigned by StringValue() to ossl_ssl_write_internal_safe(). This is a follow-up to commit https://github.com/ruby/openssl/commit/0d8c17aa855d (Reduce OpenSSL::Buffering#do_write overhead, 2024-12-21). https://github.com/ruby/openssl/commit/3ff096196a
2025-04-16[rubygems/rubygems] Fixed rubocop issue: Layout/SpaceInsideBlockBracesHiroshi SHIBATA
https://github.com/rubygems/rubygems/commit/77a52b011a
2025-04-16Run the proper version of `rake`Nobuyoshi Nakada
2025-04-15`IO.select` accepts +Float::INFINITY+ as a timeout argument.Tanaka Akira
matz accepted at the developper meeting 2024-07-11.
2025-04-15Lazily create `objspace->id_to_obj_tbl`Jean Boussier
This inverse table is only useful if `ObjectSpace._id2ref` is used, which is extremely rare. The only notable exception is the `drb` gem and even then it has an option not to rely on `_id2ref`. So if we assume this table will never be looked up, we can just not maintain it, and if it turns out `_id2ref` is called, we can lock the VM and re-build it. ``` compare-ruby: ruby 3.5.0dev (2025-04-10T09:44:40Z master 684cfa42d7) +YJIT +PRISM [arm64-darwin24] built-ruby: ruby 3.5.0dev (2025-04-10T10:13:43Z lazy-id-to-obj d3aa9626cc) +YJIT +PRISM [arm64-darwin24] warming up.. | |compare-ruby|built-ruby| |:----------|-----------:|---------:| |baseline | 26.364M| 25.974M| | | 1.01x| -| |object_id | 10.293M| 14.202M| | | -| 1.38x| ``` Notes: Merged: https://github.com/ruby/ruby/pull/13115
2025-04-12[ruby/prism] Fix parsing rescued exception via indexed assignmentviralpraxis
Given this code ```ruby begin raise '42' rescue => A[] end ``` Prism fails with this backtrace ``` Error: test_unparser/corpus/literal/rescue.txt(Prism::ParserTest): NoMethodError: undefined method `arguments' for nil prism/lib/prism/translation/parser/compiler.rb:1055:in `visit_index_target_node' prism/lib/prism/node.rb:9636:in `accept' prism/lib/prism/compiler.rb:30:in `visit' prism/lib/prism/translation/parser/compiler.rb:218:in `visit_begin_node' ``` Seems like ```diff - visit_all(node.arguments.arguments), + visit_all(node.arguments&.arguments || []), ``` fixes the problem. https://github.com/ruby/prism/commit/76d01aeb6c
2025-04-10Restore the original order of const_added and inherited callbacksXavier Noria
Originally, if a class was defined with the class keyword, the cref had a const_added callback, and the superclass an inherited callback, const_added was called first, and inherited second. This was discussed in https://bugs.ruby-lang.org/issues/21143 and an attempt at changing this order was made. While both constant assignment and inheritance have happened before these callbacks are invoked, it was deemed nice to have the same order as in C = Class.new This was mostly for alignment: In that last use case things happen at different times and therefore the order of execution is kind of obvious, whereas when the class keyword is involved, the order is opaque to the user and it is up to the interpreter. However, soon in https://bugs.ruby-lang.org/issues/21193 Matz decided to play safe and keep the existing order. This reverts commits: de097fbe5f3df105bd2a26e72db06b0f5139bc1a de48e47ddf78aba02fd9623bc7ce685540a10743 Notes: Merged: https://github.com/ruby/ruby/pull/13085
2025-04-09Fix coverage measurement for negative line numbersYusuke Endoh
Fixes [Bug #21220] Co-Authored-By: Mike Bourgeous <[email protected]> Co-Authored-By: Jean Boussier <[email protected]> Notes: Merged: https://github.com/ruby/ruby/pull/13089
2025-04-09Refine dirname test on WindowsNobuyoshi Nakada
- Compare with the root of the target file - Fix root path of UNC path Notes: Merged: https://github.com/ruby/ruby/pull/13090