Java Virtual Threads: A Case Study

This page summarizes the projects mentioned and recommended in the original post on news.ycombinator.com

InfluxDB - Purpose built for real-time analytics at any scale.
InfluxDB Platform is powered by columnar analytics, optimized for cost-efficient storage, and built with open data standards.
www.influxdata.com
featured
SaaSHub - Software Alternatives and Reviews
SaaSHub helps you find the best software and product alternatives
www.saashub.com
featured
  • runtimelab

    This repo is for experimentation and exploring new ideas that may or may not make it into the main dotnet/runtime repo.

    This FAQ is a bit outdated in places, and is not something most users should worry about in practice.

    JVM Green Threads here serve predominantly back-end scenarios, where most of the items on the list are not of concern. This list also exists to address bad habits that carried over from before the tasks were introduced, many years ago.

    In general, the perceived want of green threads is in part caused by misunderstanding of that one bad article about function coloring. And that one bad article about function coloring also does not talk about the way you do async in C#.

    Async/await in C# is just a better model with explicit understanding where a method returns an operation that promises to complete in the future or not, and composting tasks for easy (massive) concurrency is significantly more idiomatic than doing so with green threads or completable futures that existed in Java before these.

    Also one change to look for is "Runtime Handled Tasks" project in .NET that will replace Roslyn-generated state machine code with runtime-provided suspension mechanism which will only ever suspend at true suspension points where task's execution actually yields asynchronously. So far numbers show at least 5x decrease in overhead, which is massive and will bring performance of computation heavy async paths in line with sync ones: https://github.com/dotnet/runtimelab/blob/feature/async2-exp...

  • InfluxDB

    Purpose built for real-time analytics at any scale. InfluxDB Platform is powered by columnar analytics, optimized for cost-efficient storage, and built with open data standards.

    InfluxDB logo
  • spring-kafka

    Provides Familiar Spring Abstractions for Apache Kafka

    > although most of not all modern libraries have already adapted

    Unfortunately kafka, for example, has not: https://github.com/spring-projects/spring-kafka/commit/ae775...

  • AspNetCoreDiagnosticScenarios

    This repository has examples of broken patterns in ASP.NET Core applications

    It should be pointed out, that the main reason they didn't go further was because of added complexity in .NET, when async/await already exists.

    > Green threads introduce a completely new async programming model. The interaction between green threads and the existing async model is quite complex for .NET developers. For example, invoking async methods from green thread code requires a sync-over-async code pattern that is a very poor choice if the code is executed on a regular thread.

    Also to note that even the current model is complex enough to warrant a FAQ,

    https://devblogs.microsoft.com/dotnet/configureawait-faq

    https://github.com/davidfowl/AspNetCoreDiagnosticScenarios/b...

  • demo-vt-issues

    How to demonstrate virtual threads performance issues

    I looked at the replication instructions at https://github.com/blueperf/demo-vt-issues/tree/main, which reference this project: https://github.com/blueperf/acmeair-authservice-java/tree/ma...

    What "CPU-intensive apps" did they test with? Surely not acmeair-authservice-java. A request does next to nothing. It authenticates a user and generates a token. I thought it at least connects to some auth provider, but if I understand it correctly, it just uses a test config with a single test user (https://openliberty.io/docs/latest/reference/config/quickSta...). Which would not be a blocking call.

    If the request tasks don't block, this is not an interesting benchmark. Using virtual threads for non-blocking tasks is not useful.

    So, let's hope that some of the tests were with tasks that block. The authors describe that a modest number of concurrent requests (< 10K) didn't show the increase in throughput that virtual threads promise. That's not a lot of concurrent requests, but one would expect an improvement in throughput once the number of concurrent requests exceeds the pool size. Except that may be hard to see because OpenLiberty's default is to keep spawning new threads (https://openliberty.io/blog/2019/04/03/liberty-threadpool-au...). I would imagine that in actual deployments with high concurrency, the pool size will be limited, to prevent the app from running out of memory.

    If it never gets to the point where the number of concurrent requests significantly exceeds the pool size, this is not an interesting benchmark either.

  • acmeair-authservice-java

    During the login it generates a JWT which will be used by booking and customer services to validate the user.

    I looked at the replication instructions at https://github.com/blueperf/demo-vt-issues/tree/main, which reference this project: https://github.com/blueperf/acmeair-authservice-java/tree/ma...

    What "CPU-intensive apps" did they test with? Surely not acmeair-authservice-java. A request does next to nothing. It authenticates a user and generates a token. I thought it at least connects to some auth provider, but if I understand it correctly, it just uses a test config with a single test user (https://openliberty.io/docs/latest/reference/config/quickSta...). Which would not be a blocking call.

    If the request tasks don't block, this is not an interesting benchmark. Using virtual threads for non-blocking tasks is not useful.

    So, let's hope that some of the tests were with tasks that block. The authors describe that a modest number of concurrent requests (< 10K) didn't show the increase in throughput that virtual threads promise. That's not a lot of concurrent requests, but one would expect an improvement in throughput once the number of concurrent requests exceeds the pool size. Except that may be hard to see because OpenLiberty's default is to keep spawning new threads (https://openliberty.io/blog/2019/04/03/liberty-threadpool-au...). I would imagine that in actual deployments with high concurrency, the pool size will be limited, to prevent the app from running out of memory.

    If it never gets to the point where the number of concurrent requests significantly exceeds the pool size, this is not an interesting benchmark either.

  • SaaSHub

    SaaSHub - Software Alternatives and Reviews. SaaSHub helps you find the best software and product alternatives

    SaaSHub logo
NOTE: The number of mentions on this list indicates mentions on common posts plus user suggested alternatives. Hence, a higher number means a more popular project.

Suggest a related project