[pull] master from ruby:master - #1338
Merged
Merged
Conversation
native_thread_dedicated_inc/dec run on every blocking region boundary and
took ractor.sched.lock each way just to move two counters. Make snt_cnt a
seq-cst atomic: leaving the pool is one FETCH_SUB, and rejoining is a CAS
loop that enforces the max_cpu cap. The lock is taken only when the last
snt goes dedicated, to check grq_cnt and wake the timer thread.
The lost-wakeup gate stays sound as a store-buffer pair: ractor_sched_enq
raises grq_cnt and then reads snt_cnt; dedicated_inc lowers snt_cnt and
then reads grq_cnt under the lock, so at least one side sees the other.
Both increment paths (rejoin and pool widening) check the cap and then
CAS, so max_cpu still holds without the lock.
dnt_cnt only ever fed one RUBY_DEBUG_LOG line, so define and update it
only under USE_RUBY_DEBUG_LOG, without atomicity; nothing may read it
for decisions.
R ractors x 1 thread each doing pipe write/read round-trips on a 16-HT
machine (Ryzen 9 5900HX), round-trips/sec, median of repeated runs:
R master patched
1 422k 430k +2%
2 718k 752k +5%
4 933k 1,036k +11%
8 905k 1,111k +23%
16 735k 1,016k +38%
32 671k 955k +42%
64 690k 952k +38%
128 685k 946k +38%
master peaks at 4 ractors and degrades under lock contention; patched
peaks at 8 and holds up to 128. Single-ractor shapes are unchanged.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
and allow to declare `dnt_cnt` only for logging.
If we embed the iseq_body, then it won't be a stable address, so we shouldn't depend on the pointer address as a stable hash key. We can instead use the location where it's defined as the hash key.
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 : )