Skip to content

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

Closed

Description

@sorumehta

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+

Activity

  1. sorumehta commented on Sep 22, 2023

    @sorumehta
    Author

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

  2. lihaoyi commented on Sep 22, 2023

    @lihaoyi
    Member

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

  3. lloydmeta commented on Jan 14, 2024

    @lloydmeta

    Is this something that #74 unblocks?

  4. changed the title [-]Use Java Virtual Threads (Loom)[/-] [+]Use Java Virtual Threads (Loom) (500USD Bounty)[/+] on May 14, 2024
  5. andreak commented on May 15, 2024

    @andreak

    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

  6. lihaoyi commented on May 15, 2024

    @lihaoyi
    Member

    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.

  7. He-Pin commented on May 19, 2024

    @He-Pin
    Contributor

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

  8. sideeffffect commented on Jul 22, 2024

    @sideeffffect

    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/

  9. lihaoyi commented on Sep 15, 2024

    @lihaoyi
    Member

    FYI for anyone reading, this bounty is still open in case anyone else wants to take a crack at this

  10. sorumehta commented on Sep 19, 2024

    @sorumehta
    Author

    @lihaoyi Since I started this issue, I am going to finish it too. :)

  11. sorumehta commented on Sep 23, 2024

    @sorumehta
    Author

    while building cask, twirl throws java.lang.reflect.InvocationTargetException

  12. jodersky commented on Nov 5, 2024

    @jodersky
    Member

    while building cask, twirl throws java.lang.reflect.InvocationTargetException

    I get that too when building on JDK >= 21. Maybe the newer 2.0.x works better.

  13. jodersky commented on Nov 27, 2024

    @jodersky
    Member

    Looks like it wasn't twirl afterall (probably, just a cached coincidence when I switched JDK version). See #154.

  14. He-Pin commented on Jan 11, 2025

    @He-Pin
    Contributor

    @sorumehta @jodersky I bought a MacBook for this :) .

  15. He-Pin commented on Jan 11, 2025

    @He-Pin
    Contributor

    @sideeffffect As all the dispatching layers are done in cask, I think Netty/Vert.x is an option, too?

  16. added a commit that references this issue on Jan 18, 2025
  17. He-Pin commented on Jan 19, 2025

    @He-Pin
    Contributor

    @sorumehta BTW, I was superized by the performance, which is quite good, at least many systems only have < 1qps.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions