GithubHelp home page GithubHelp logo

Comments (18)

vietj avatar vietj commented on September 27, 2024

@rikvb as I understand this happens because the check is registered by Graal when the native image is built and instead it should be lazily done ?

from vert.x.

vietj avatar vietj commented on September 27, 2024

@cescoffier is there any way we can improve this with some graal vm declaration ?

from vert.x.

rikvb avatar rikvb commented on September 27, 2024

@rikvb as I understand this happens because the check is registered by Graal when the native image is built and instead it should be lazily done ?

Without the explicit hints the mentioned classes and methods are not available in the native image, resulting in the check failing and vert.x thinking the runtime does not support virtual threads (even though it does).

from vert.x.

cescoffier avatar cescoffier commented on September 27, 2024

@vietj it's typically things we do directly in Quarkus (which unfortunately cannot be replicated here).

We prefer not to use the reachability project - it's rare when one size fits all, especially around Vert.x and Netty.

We can try with something like: https://github.com/netty/netty/blob/4.1/codec/src/main/resources/META-INF/native-image/io.netty/netty-codec/generated/handlers/reflect-config.json. I can't remember what it does if the method/class/field is not available.

from vert.x.

vietj avatar vietj commented on September 27, 2024

thanks @cescoffier

from vert.x.

vietj avatar vietj commented on September 27, 2024

@rikvb can you provide a reproducer project with instructions ?

from vert.x.

rikvb avatar rikvb commented on September 27, 2024

virtual-threads-examples.zip
I've attached a stripped down version of the virtual threads example with some spring boot and graal additions.

  1. run 'mvn clean compile spring-boot:process-aot spring-boot:build-image -P native'
  2. docker run docker.io/library/virtual-threads-examples:4.5.4

Output:

  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::                (v3.2.3)

Mar 22, 2024 4:17:46 PM org.springframework.boot.StartupInfoLogger logStarting
INFO: Starting AOT-processed HttpClientExample using Java 21.0.2 with PID 1 (/workspace/io.vertx.example.virtualthreads.HttpClientExample started by cnb in /workspace)
Mar 22, 2024 4:17:46 PM org.springframework.boot.SpringApplication logStartupProfileInfo
INFO: No active profile set, falling back to 1 default profile: "default"
Mar 22, 2024 4:17:46 PM org.springframework.boot.StartupInfoLogger logStarted
INFO: Started HttpClientExample in 0.011 seconds (process running for 0.012)
Exception in thread "main" java.util.concurrent.ExecutionException: io.vertx.core.impl.NoStackTraceThrowable: This Java runtime does not support virtual threads
        at [email protected]/java.util.concurrent.CompletableFuture.reportGet(CompletableFuture.java:396)
        at [email protected]/java.util.concurrent.CompletableFuture.get(CompletableFuture.java:2073)
        at io.vertx.example.virtualthreads.HttpClientExample.main(HttpClientExample.java:27)
        at [email protected]/java.lang.invoke.LambdaForm$DMH/sa346b79c.invokeStaticInit(LambdaForm$DMH)
Caused by: io.vertx.core.impl.NoStackTraceThrowable: This Java runtime does not support virtual threads

from vert.x.

vietj avatar vietj commented on September 27, 2024

thanks @rikvb

from vert.x.

vietj avatar vietj commented on September 27, 2024

I tried running it and got rosetta error: failed to open elf at /lib64/ld-linux-x86-64.so.2 on my M1 macbook, any idea :-) @rikvb ?

from vert.x.

vietj avatar vietj commented on September 27, 2024

since I'm building this on my laptop I would not expect this issue to happen

from vert.x.

vietj avatar vietj commented on September 27, 2024

stephenh/ts-proto#849

from vert.x.

vietj avatar vietj commented on September 27, 2024

I'm able to reproduce now with the right Paketo thing (I don't know what it does, looks like it's quite complex :-) )

from vert.x.

vietj avatar vietj commented on September 27, 2024

it seems we can compute this per vertx instance instead of being static, I think this would solve this problem.

from vert.x.

vietj avatar vietj commented on September 27, 2024

actually this does not seem to be enough

from vert.x.

rikvb avatar rikvb commented on September 27, 2024

Not sure it would, unless you can prevent using reflection.

from vert.x.

vietj avatar vietj commented on September 27, 2024

@rikvb could you provide a version of the reproducer that works without Spring ? I would like to use it to test native image compatibility when releasing vertx

from vert.x.

rikvb avatar rikvb commented on September 27, 2024

I will look into it, but I have no experience on graalvm without the spring boot maven plugin so it might take me a bit.

from vert.x.

rikvb avatar rikvb commented on September 27, 2024

virtual-threads-examples-nospring.zip

Ok so here's a reproducer that does not use spring. On Windows this produces an executable that prints the following:

.\virtual-threads-examples.exe
Apr 09, 2024 5:31:09 PM io.vertx.core.spi.resolver.ResolverProvider
INFO: Using the default address resolver as the dns resolver could not be loaded
Exception in thread "main" java.util.concurrent.ExecutionException: io.vertx.core.impl.NoStackTraceThrowable: This Java runtime does not support virtual threads
        at [email protected]/java.util.concurrent.CompletableFuture.reportGet(CompletableFuture.java:396)
        at [email protected]/java.util.concurrent.CompletableFuture.get(CompletableFuture.java:2073)
        at io.vertx.example.virtualthreads.HttpClientExample.main(HttpClientExample.java:22)
        at [email protected]/java.lang.invoke.LambdaForm$DMH/sa346b79c.invokeStaticInit(LambdaForm$DMH)
Caused by: io.vertx.core.impl.NoStackTraceThrowable: This Java runtime does not support virtual threads

However, to build this I need to use graalvm-jdk. In the spring-based example I used a regular OpenJDK. To get output above I used graalvm-jdk-21_windows-x64

Hope this helps.

from vert.x.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.