Support for fiber scheduler API#7944
Merged
headius merged 34 commits intojruby:masterfrom Oct 31, 2023
Merged
Conversation
This was referenced Oct 11, 2023
* Only IO endpoints calling back into scheduler so far * IO::Buffer totally stubbed out * Organization of utility methods likely to change
For test_io_buffer.rb:test_inplace_operators This also necessitated implementing initialize_copy for the dup'ed buffer in the test, along with to_s, inspect, and hexdump for when there's an error condition.
Moving to Java 13+ would allow us to do absolute puts without the position changing.
Position is not part of IO::Buffer so we must constantly reset it.
Pushing toward the blessed path always receiving a ByteBuffer, so we can avoid recreating it constantly for small reads.
This unfortunately does not work for most files in JRuby, since we usually use a real native file descriptor on POSIX platforms. This will need to be expanded to work with a native fileno but produce a MappedByteBuffer.
This doesn't pass test_string_mapped because we do not lock String objects like MRI does and cannot raise an error when the String owned by the Buffer is modified independently.
6f6c79d to
c726bcf
Compare
This cleans up how blocking works and fixes small parts of the scheduler dispatch logic. Fibers start out nonblocking by default, which means entering such a fiber puts the system in a schedulable state (decrements root fiber's default blocking count of 1 to 0). While schedulable, blocking calls will redispatch into the scheduler to give it a chance to handle the blocking operation and optionally transfer to another unblocked fiber. The handling of blocking and unblocking will require some additional work, since currently only a fiber yielding can unblock its parent, but we are getting the pieces wired up. All of CRuby's test/fiber/test_scheduler.rb passes with these changes.
It still all passes 🎉
Working on failures in mri/fiber/test_io_buffer.rb
* This includes two PRs to improve behavior and testing: * ruby/ruby#8728 * ruby/ruby#8729
4ae1fd7 to
68e1955
Compare
68e1955 to
2779806
Compare
54a8d4b to
6b96a41
Compare
Member
Author
|
We will ship this, disabled, in 9.4.5.0. Set property |
This commit adds the property "jruby.experimental.fiber.scheduler" to control whether the Fiber::Scheduler subsystem will be used at runtime. It is currently off by default, as this is an experimental feature in all versions of Ruby that support it. Set this property at the JVM level, or pass -Xexperimental.fiber.scheduler to enable it. None of the classes or constants associated with the fiber scheduler will be defined if the property is not enabled. In the future, this property may disappear when this feature is finalized, or may remain under a different name to allow disabling all scheduler checks.
6b96a41 to
fef81e6
Compare
headius
added a commit
to headius/jruby
that referenced
this pull request
Feb 13, 2024
As part of moving toward the scheduler API, several methods from the io-wait gem have been moved into IO proper. Preliminary support for the scheduler API was merged in jruby#7944.
headius
added a commit
to headius/jruby
that referenced
this pull request
Feb 13, 2024
As part of moving toward the scheduler API, several methods from the io-wait gem have been moved into IO proper. Preliminary support for the scheduler API was merged in jruby#7944.
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.
Work in progress. Mostly modeling this after logic on CRuby HEAD.
Optimistically marking this for 9.4.5 but probably would be better to drop in the next major release.