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

Use Java Virtual Threads (Loom) (500USD Bounty) #90

Open
sorumehta opened this issue Sep 20, 2023 · 6 comments · May be fixed by #125
Open

Use Java Virtual Threads (Loom) (500USD Bounty) #90

sorumehta opened this issue Sep 20, 2023 · 6 comments · May be fixed by #125

Comments

@sorumehta
Copy link

sorumehta commented Sep 20, 2023

Spawn a virtual thread for each incoming request, which would enable asynchronous behaviour and increase performance of the library. The new Java virtual threads are lightweight and can replace the traditional Java threads. Given that Cask does not have any strong async/concurrency model of its own, leveraging the new JVM feature would be really nice.

Haoyi: To incentivize contribution, I'm putting a 500USD bounty on resolving this ticket. This is payable via bank transfer, and at my discretion in case of ambiguity. The acceptance criteria is a PR implementing support for virtual threads, tests exercising them, and performance benchmarks (ad-hoc is OK) demonstrating a performance improvement (e.g. in high concurrency use cases) vs normal threads in Java 21+

@sorumehta
Copy link
Author

I can create a PR for this if this seems like a good idea to @lihaoyi

@lihaoyi
Copy link
Member

lihaoyi commented Sep 22, 2023

Go for it, though note we'll need some compatibility story for Java <21

@lloydmeta
Copy link

Is this something that #74 unblocks?

@lihaoyi lihaoyi changed the title Use Java Virtual Threads (Loom) Use Java Virtual Threads (Loom) (500USD Bounty) May 14, 2024
@andreak
Copy link

andreak commented May 15, 2024

I would recommend against this until JAVA-23 is released, du to the "pinning issue", effectively making Virtual Threads useless if your code/libs uses synchronized a lot.
https://www.infoworld.com/article/3713220/java-virtual-threads-hit-with-pinning-issue.html

@lihaoyi
Copy link
Member

lihaoyi commented May 15, 2024

Doing it opt-in should be fine. We can run benchmarks etc. without synchronized to see the benefit. That way we can be ready on day one when Java 23 lands with a fix to the thread pinning issue.

@He-Pin
Copy link
Contributor

He-Pin commented May 19, 2024

I have done this at $work for all my services, with Java 21, it works fine, no need to delay to Java 23.

@He-Pin He-Pin linked a pull request May 19, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants