You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Use Java Virtual Threads (Loom) (500USD Bounty)Β #90
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+
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.
If there are issues because of undertow, you may consider switching to Helidon, which is the new web server from Oracle, built for working with virtual threads.
Activity
sorumehta commentedon Sep 22, 2023
I can create a PR for this if this seems like a good idea to @lihaoyi
lihaoyi commentedon Sep 22, 2023
Go for it, though note we'll need some compatibility story for Java <21
lloydmeta commentedon Jan 14, 2024
Is this something that #74 unblocks?
[-]Use Java Virtual Threads (Loom)[/-][+]Use Java Virtual Threads (Loom) (500USD Bounty)[/+]andreak commentedon 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
synchronizeda lot.https://www.infoworld.com/article/3713220/java-virtual-threads-hit-with-pinning-issue.html
lihaoyi commentedon 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 commentedon 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.
sideeffffect commentedon Jul 22, 2024
If there are issues because of undertow, you may consider switching to Helidon, which is the new web server from Oracle, built for working with virtual threads.
https://helidon.io
https://github.com/helidon-io/helidon/tree/main/webserver
https://central.sonatype.com/artifact/io.helidon.webserver/helidon-webserver/overview
https://javadoc.io/doc/io.helidon.webserver/helidon-webserver/
lihaoyi commentedon Sep 15, 2024
FYI for anyone reading, this bounty is still open in case anyone else wants to take a crack at this
sorumehta commentedon Sep 19, 2024
@lihaoyi Since I started this issue, I am going to finish it too. :)
sorumehta commentedon Sep 23, 2024
while building cask, twirl throws java.lang.reflect.InvocationTargetException
jodersky commentedon Nov 5, 2024
I get that too when building on JDK >= 21. Maybe the newer 2.0.x works better.
jodersky commentedon Nov 27, 2024
Looks like it wasn't twirl afterall (probably, just a cached coincidence when I switched JDK version). See #154.
He-Pin commentedon Jan 11, 2025
@sorumehta @jodersky I bought a MacBook for this :) .
He-Pin commentedon Jan 11, 2025
@sideeffffect As all the dispatching layers are done in cask, I think Netty/Vert.x is an option, too?
feat: Add loom Support. (#159)
He-Pin commentedon Jan 19, 2025
@sorumehta BTW, I was superized by the performance, which is quite good, at least many systems only have < 1qps.