[pull] master from ruby:master - #1290
Merged
Merged
Conversation
* https://logs.rubyci.org/osx1400arm/ruby-master/log/20260807T174503Z.fail.html.gz 1) File.setgid? accepts a path in a non-UTF-8, ASCII-compatible encoding containing non-ASCII characters FAILED Expected false == true to be truthy but was false /Users/hsbt/chkbuild/tmp/build/20260807T174503Z/ruby/spec/ruby/shared/file/setgid.rb:11:in 'block (3 levels) in <top (required)>' /Users/hsbt/chkbuild/tmp/build/20260807T174503Z/ruby/spec/ruby/core/file/setgid_spec.rb:4:in '<top (required)>' 2) File::Stat#setgid? accepts a path in a non-UTF-8, ASCII-compatible encoding containing non-ASCII characters FAILED Expected false == true to be truthy but was false /Users/hsbt/chkbuild/tmp/build/20260807T174503Z/ruby/spec/ruby/shared/file/setgid.rb:11:in 'block (3 levels) in <top (required)>' /Users/hsbt/chkbuild/tmp/build/20260807T174503Z/ruby/spec/ruby/core/file/stat/setgid_spec.rb:5:in '<top (required)>' 3) FileTest.setgid? accepts a path in a non-UTF-8, ASCII-compatible encoding containing non-ASCII characters FAILED Expected false == true to be truthy but was false /Users/hsbt/chkbuild/tmp/build/20260807T174503Z/ruby/spec/ruby/shared/file/setgid.rb:11:in 'block (3 levels) in <top (required)>' /Users/hsbt/chkbuild/tmp/build/20260807T174503Z/ruby/spec/ruby/core/filetest/setgid_spec.rb:4:in '<top (required)>'
This commit centralizes shape setting for objects in the ZJIT GC fastpath into the rb_zjit_new_obj_shape function to avoid each type having to deal with shapes individually.
Rewrite FixnumMod with a positive power-of-two constant divisor into FixnumAnd, and FixnumDiv into FixnumRShift. The sign of Ruby's modulo result follows the divisor, and Integer#/ rounds the quotient towards negative infinity, so both rewrites hold for all fixnum dividends and replace a C call with a single ALU instruction.
This also enables the alloc fastpath where it previously wasn't enabled when `-DRUBY_DEBUG` is set in cflags during compilation. This will allow us to test the ZJIT alloc fastpath in CI and when running ZJIT tests locally in dev (--enable-zjit=dev) or debug mode (cflags="-DRUBY_DEBUG=1").
The allocation fastpath just advances the cursor and we don't want to emit code that checks for this rare case. Emit a patchpoint instead and invalidate the allocation fastpath code when NEWOBJ hooks are enabled for the first time.
1) Remove copied code in gc_fastpath.rs 2) RbGcZjitDefaultNewObjFastpath and RbGcZjitMmtkNewObjFastpath structs were copied from the cruby_bindings file. 3) Get MMTK to use the newobj hook patchpoint for ZJIT's alloc fastpath. Previously only the default GC used this patchpoint. MMTK had to check if newobj hooks were enabled in its fastpath, which it no longer does. 4) ractor_belonging_id has been removed
The Ractor root scan marked each thread's ec directly and then marked the
wrapper of the fiber that ec lives in. Both reach rb_execution_context_mark,
so every thread's machine stack was scanned conservatively twice per
collection -- with 5000 threads, 750270 scans where 362326 were needed.
Marking the fiber wrapper is enough: th->ec is &fiber->cont.saved_ec (thread_mark
asserts as much), the wrapper goes on the mark stack during the root scan, and
the stack drains before anything is swept. Only when there is no wrapper yet,
mid-creation or teardown, does the ec still need marking of its own.
benchmark/vm_thread_pass_flood.rb, which floods 5000 threads:
collections 157 157 (unchanged)
time in GC 0.84s -> 0.49s
thread creation 1.17s -> 0.81s
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
gcc stopped inlining the small helpers gc_mark calls for every reference it
marks. From -fopt-info-inline on gc.c, before and after the per-Ractor GC
landed:
gc_mark_set -> gc_mark 10 -> 2
gc_mark_check_t_none -> gc_mark 8 -> 0
rgengc_check_relation -> gc_mark 8 -> 4
RVALUE_AGE_INC -> gc_aging 2 -> 0
gc.c is one translation unit -- it includes the whole default implementation --
so gcc's growth budget is spent across all of it, and the added code pushed
these out even though none of it runs on this path. Marking then pays a call
per reference.
Pin them with ALWAYS_INLINE. .text does not grow (5834940 -> 5834812 bytes):
what the inlining adds, the vanished call sequences take back.
Instructions retired, and wall clock as the best of seven runs:
60 full collections, 207k live 3.74G -> 3.48G 0.39s -> 0.33s
marking objects, hashes and classes 3.67G -> 3.43G
allocation loop (40M []) 14.17G -> 13.85G 0.92s -> 0.86s
allocation mixed with collection 18.06G -> 17.74G 1.28s -> 1.18s
binary trees (depth 16) 34.42G -> 34.15G 3.06s -> 3.00s
Time moves more than the instruction count does: what goes away is a call and
its register traffic on every marked reference.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
See Commits and Changes for more details.
Created by
pull[bot] (v2.0.0-alpha.4)
Can you help keep this open source service alive? 💖 Please sponsor : )