-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Coroutines support? #477
Comments
I think it will be a while, but I also hope we eventually get them. The challenge is that the JVM itself doesn't support green thread/coroutines/fibers and graal cannot add them without support since Graal still uses the JVMs support for managing stacks and heap (and rewriting stacks during deopt and OSR). @eregon's work Mozart-Graal uses a modified JVM 8 which supports coroutines. This work on JVM coroutines was part of MLVM back when that was a thing, but I don't think it ever even became a JSR and died at the prototype stage. I was kinda bummed. I think it would have been great to have it in unmodified JVMs. For more details on this and related stuff I recommend oracle/truffleruby#106 which discusses this issue in the context of Ruby. One thing to note though is that you could implement coroutines for a Graal/Truffle language. The restriction would be that you could only suspend the parts of the stack that are in YOUR language, so it wouldn't work with all the GraalVM interop stuff. However, the performance overhead could be pretty limited since you would only need to compile in the coroutine support in functions which actually suspend, mostly avoiding the overhead in non-suspending cases. My language (Orc) uses selective continuation-passing style to implement what are basically coroutines (though in my case I only use them to schedule concurrent tasks). |
I think it's worth noting that Project Loom, an existing OpenJDK sub-project, is looking into implementing fibers and delimited continuations, both of which I understand are related to coroutines. |
@yrsh I admit I don't know if anyone uses Loom in production yet. I'd be surprised if that were the case, as I don't think it's come that far yet. And yeah, I can see what you mean by how it seems suspended. I don't know why there's been a lack of activity recently. I understand that @pron is or was working on Project Loom... :) |
@yrsh Looks like Loom has seen some more activity just now. In fact, looks like a public prototype is available now! |
Yes. We've been working with the Graal team to add Graal support, which you can try right now (although not in SubstrateVM as of yet). |
https://medium.com/graalvm/bringing-fibers-to-truffleruby-1b5d2e258953 by @chrisseaton shows some promising results for using Loom's |
@pron any estimate as to when Loom will land on SVM? |
As an aside, trying @pron I will probably use uninstrumented variants as the near-term solution for my use case, a serverless function. |
Do you think that's a Native Image error? Is it compliant bytecode that Native Image isn't anticipating because it isn't emitted by the Java or Scala compilers? |
@chrisseaton how about I make a minimum test case? I believe it is the same error as this: quarkusio/quarkus#1957 (comment) Which uses the same instrumenting code, just under a different package name / fork. |
Yes seems relevant - someone just needs to pass it up to the SVM team with a minimum test case. It can probably be bytecode post-instrumentation if that makes the setup easier. |
@chrisseaton I haven't forgotten about this I hope to get to a repro by the start of next week. I will have most trouble setting up the test. |
I never got around to this because I could never get Graal building on my macOS machine. I needed a guide! Otherwise, can I just provide a Graal-built fat JAR that contains bytecode that fails instrumentation versus the same, uninsturmented version of that JAR that works? That I can definitely do. |
See #2546 @chrisseaton |
hi @yrsh , this issue has been inactive for more than 180 days. We’ll close it to focus on current issues. In case it’s still relevant, please reopen it and we’ll take another look. Thank you! |
Is it expected to support green threads or coroutines?
The text was updated successfully, but these errors were encountered: