-
Notifications
You must be signed in to change notification settings - Fork 185
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fiber / green threads / coroutines? #106
Comments
Currently TruffleRuby uses Java threads for Fibers. The standard JVM does not yet support native coroutines. I am using that patch in my Oz language implementation. So we might use that to try what would be the benefits of native coroutines, but it is unpractical as it requires a custom JVM build. Do you have any particular library or application in mind where it is important to have lightweight Fibers? |
This is documented in our compatibility document. I've updated it a bit to say some more about fibers. Fibers, continuations and coroutines are all things that fundamentally don't match the execution model we are using at the moment and are unlikely to every be implemented with the same performance characteristics as MRI. It's a shame, but it's one of a very few hard compatibility limitations we have. |
@chrisseaton I don't believe coroutines (not continuations) "fundamentally don't match the execution model we are using at the moment". See my previous answer. |
To clarify, when I say 'fundamentally doesn't match our execution model' I mean running on an unmodified JVM. Benoit is talking about things which may be possible with modified JVMs or the SubstrateVM. |
Thanks for your responses. My use-case is related to celluloid and other programming libraries that hide asynchronous behavior behind a Fiber-based synchronous interface. At times there can be hundreds or thousands of fibers utilized by the libraries, so lightweight fibers are useful in that regard. I would like to use TruffleRuby for a few proof-of-concept projects. I will likely need to implement some kind of fiber pooling mechanism to prevent run away thread allocation. If I discover anything interesting, I'll be sure to share it with you all. |
FWIW reusing FIber threads is something relatively easy, just not done currently in TruffleRuby (patch welcome!). |
* commit 'f45d5739edf37d2a03ee944a7da137aa1ad1667b': Use mx native-image instead of ./native-image
For information, Fibers now use a thread pool, so the cost to create many of them should be much lower. |
Point to our fork of graal on jt Merge-Requested-By: rafaelfranca Merge-Queue-Digest: 5086b6fbf6fa3b11a9406903a500642ab948d7cc850b6becb25692c13d312128
What is the plan for supporting Fibers? Right now JRuby backs each Fiber with a thread which is rather heavy on resources. Will TruffleRuby support anything lighter like green threads or coroutines to support the Fiber?
The text was updated successfully, but these errors were encountered: