Repository navigation
Conversation
Member
Author
|
This didn't make the cut for 9.3, which we wanted to get out the door to work on Ruby 3.0 support in 9.4. Punting to 9.4 to reevaluate. |
headius
force-pushed
the
spooky_fibers
branch
from
November 4, 2022 19:00
741075e to
42133e5
Compare
Member
Author
|
Rebased on master. With recent changes to fibers, we'll see how this goes in CI. It's not something I'd like to drop in an update release, so if we are green with this change now might be the time to push it through. |
headius
force-pushed
the
spooky_fibers
branch
from
November 4, 2022 19:07
42133e5 to
25092f4
Compare
This is the start of experiments in making Thread.current, among other things, pretend that a Fiber is equivalent to its master thread, rather than being its own thread. This work was triggered by me running the socketry/async specs and seeing that there's some locking done across fibers that's expected to treat them all as owning the lock. In this case, it's an RSpec reentrant lock implementation that aggregates a Mutex and the thread that acquired it and compares that thread with Thread.current to avoid relocking. For JRuby the following changes were needed to make the lock work: * Thread.current must point at the "Fiber current thread" rather than the "Fiber thread". We have attempted this in the past and run afoul of system-level locking that saw through to the real locks. * Mutex#owned? had to do a similar check, aggregating a reference to the Fiber current thread that originally locked it and using that for comparison with the current Fiber current thread. With these changes the async specs run to completion with 16 errors that I have not looked into yet.
headius
force-pushed
the
spooky_fibers
branch
from
November 16, 2022 21:42
25092f4 to
7c225cf
Compare
Member
Author
|
There appears to be several hanging tests, so something is not right here. |
Member
Author
|
Going to reboot this on a separate branch and PR. |
headius
added a commit
to headius/jruby
that referenced
this pull request
Aug 31, 2026
A few step toward getting Thread.current in general to behave like CRuby, returning the same Thread for all Fiber instances that it owns. Behind the scenes, each Fiber is still backed by a VirtualThread with an associated ThreadContext and RubyThread, but user code should generally not see those. Additional fixes will follow for internal code that has expectations about the current thread of a fiber. See other attempts to do this and issues related: * My attempt: jruby#5827 * Community attempt: jruby#1225 * An early issue: jruby#1806 Relates to test failures mentioned in jruby#9603 and workarounds from users in jruby#9600.
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 join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This is the start of experiments in making Thread.current, among other things, pretend that a Fiber is equivalent to its master thread, rather than being its own thread.
This work was triggered by me running the socketry/async specs and seeing that there's some locking done across fibers that's expected to treat them all as owning the lock. In this case, it's
an RSpec reentrant lock implementation that aggregates a Mutex and the thread that acquired it and compares that thread with Thread.current to avoid relocking.
For JRuby the following changes were needed to make the lock work:
locks.
With these changes the async specs run to completion with 16 errors that I have not looked into yet.
See #1806.