Skip to content
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

[GR-34749] Continuation support independent of Project Loom. #4114

Merged
merged 24 commits into from
Feb 4, 2022

Conversation

graalvmbot
Copy link
Collaborator

@graalvmbot graalvmbot commented Dec 11, 2021

This change refactors our fundamental implementation of continuations so it does not require a Project Loom JDK, and adds our own implementation of virtual threads (as opposed to platform threads, i.e. OS threads). With no support in the JDK code for yielding a virtual thread when it blocks on I/O, we cannot ensure progress if we limit the number of backing platform threads, so in the worst case, the default backing thread pool creates a platform thread for each virtual thread. This, of course, currently makes virtual threads less viable for what continuations are usually intended for.

Future changes will refactor the structure of stored continuation stacks and avoid doing stack walks on them eagerly and instead let the garbage collector walk them on demand.

@peter-hofer peter-hofer changed the title [GR-34749] [GR-34749] Continuation support independent of Project Loom. Dec 12, 2021
@peter-hofer peter-hofer self-assigned this Dec 12, 2021
@graalvmbot graalvmbot force-pushed the github/ph/GR-34749 branch 10 times, most recently from 1326b8c to 82a59de Compare December 17, 2021 13:15
@graalvmbot graalvmbot force-pushed the github/ph/GR-34749 branch 4 times, most recently from a6e156e to 177f485 Compare December 23, 2021 19:05
@LifeIsStrange
Copy link

I wonder how it compares to Loom and Kotlin coroutines

@peter-hofer
Copy link
Member

@LifeIsStrange this implementation is similar to that of Project Loom, but not optimized or well-tested yet. There are some potential advantages we have however, such as our monitor implementation using ReentrantLock which uses LockSupport and so already supports yielding, and not having to worry about interpreter frames. We will not support yielding on I/O blocking though unless the necessary JDK changes are merged, presumably together with the rest of Project Loom.

@graalvmbot graalvmbot force-pushed the github/ph/GR-34749 branch 2 times, most recently from db39dc0 to bcedb19 Compare January 10, 2022 20:16
@graalvmbot graalvmbot force-pushed the github/ph/GR-34749 branch 4 times, most recently from 25d8798 to bfa4894 Compare January 31, 2022 20:02
…ys (almost) write interrupted flag even when already interrupted.
@graalvmbot graalvmbot merged commit a3e0253 into master Feb 4, 2022
@graalvmbot graalvmbot deleted the github/ph/GR-34749 branch February 8, 2022 01:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants