Comments (7)
@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.
Using that patch would allow to have similar performance characteristics as MRI.
But yes, it's not practical to require a custom JVM build of course.
I agree it's better to be clear in compatibility: we don't support coroutines in the current distribution and use threads for Fibers.
But there is nothing fundamentally impossible here.
from truffleruby.
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.
from truffleruby.
Currently TruffleRuby uses Java threads for Fibers.
The standard JVM does not yet support native coroutines.
However, Lukas Stadler made a patch to add native coroutine support (http://ssw.jku.at/General/Staff/LS/coro/).
I am using that patch in my Oz language implementation.
The patched JVM is at https://github.com/eregon/jvmci and the corresponding API in https://github.com/eregon/truffle/tree/coro, which uses threads or coroutines depending on the JVM it runs on.
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?
Thread switching is not so much slower, but they use more memory.
from truffleruby.
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.
from truffleruby.
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.
from truffleruby.
FWIW reusing FIber threads is something relatively easy, just not done currently in TruffleRuby (patch welcome!).
https://github.com/eregon/truffle/blob/247496f4984d9f08775f165cd7538a6d4c0dd90b/truffle/com.oracle.truffle.coro/src/com/oracle/truffle/coro/ThreadCoroutineSupport.java#L108
from truffleruby.
For information, Fibers now use a thread pool, so the cost to create many of them should be much lower.
from truffleruby.
Related Issues (20)
- Serious performance regression for method pow(a, m) HOT 7
- Prepending a module to Integer disables many Inlined*Node
- method_source compatibility problems introduced with TruffleRuby 24.0.0 HOT 3
- Error installing pg 1.1.4 HOT 1
- concurrent-ruby Fixed Thread Pool memory leak HOT 2
- Array#pack does not support :buffer kwarg HOT 1
- Monkey patching not working HOT 2
- TruffleRuby set `host_cpu` to `aarch64` on `arm64-darwin` causing `REUSE_AS_BINARY_ON_TRUFFLERUBY` to not work as expected HOT 3
- rails 7, rails new - no such filre or directory HOT 1
- gem error: OpenSSL is not available in Oracle Linux 9 HOT 4
- How to call a method from java whose name is send? HOT 2
- dead handle with mongoid HOT 8
- Benchmark ORM on Truffleruby vs CRuby HOT 1
- using "find pattern" matching in a dynamically-defined method results in NPE HOT 3
- Segfault in 24.1.0-dev GFTC builds with pg driver HOT 6
- `StringIO` does not set the ASCII-8BIT encoding in `wb` mode HOT 1
- Hash.to_h with block not yielding splat args well HOT 2
- Documentation: installing TruffleRuby in JVM mode from RVM HOT 1
- Segfault in 24.2.0-dev GFTC when bundle installing HOT 4
- Java exceptions not caught by bare rescue HOT 8
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from truffleruby.