Comments (18)
@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.
@cescoffier is there any way we can improve this with some graal vm declaration ?
from vert.x.
@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.
@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.
thanks @cescoffier
from vert.x.
@rikvb can you provide a reproducer project with instructions ?
from vert.x.
virtual-threads-examples.zip
I've attached a stripped down version of the virtual threads example with some spring boot and graal additions.
- run 'mvn clean compile spring-boot:process-aot spring-boot:build-image -P native'
- 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.
thanks @rikvb
from vert.x.
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.
since I'm building this on my laptop I would not expect this issue to happen
from vert.x.
from vert.x.
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.
it seems we can compute this per vertx instance instead of being static, I think this would solve this problem.
from vert.x.
actually this does not seem to be enough
from vert.x.
Not sure it would, unless you can prevent using reflection.
from vert.x.
@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.
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.
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)
- Vert.x Upgrade from 3.7.1 to 3.9.16 causing infinite websocket reconnections HOT 1
- Add DNS-over-HTTPS (DoH) Support to Vert.x
- ThreadingModel.VirtualThread significant performance drop. HOT 5
- Vertx in native image throws error : This java rumtime does not support virtual threads HOT 3
- FileSystem#readDir is not cancelled when circuit breaker timeout kicks in and blocks further readDir calls HOT 1
- Support Marker for Logger spi. HOT 1
- HTTP trailers in requests HOT 1
- java.util.NoSuchElementException thrown after the HttpClientRequest.reset() is called. HOT 2
- Vert.x stress test problem after 16xxx request sent HOT 8
- io.vertx.ext.web.RoutingContext json() method not reporting json.EncodeException HOT 1
- performance degradation when no handler HOT 1
- Resource segregation
- Received HTTP message with no request in progress HOT 4
- Access the vertx instance from HttpClient objects HOT 1
- Event executor provider SPI
- Micrometer configuration lifecycle violation HOT 2
- HttpServerRequest connection.close() does not trigger exceptionHandler() HOT 1
- HAManager couldn't see quorum if during its initialization cluster manager has all nodes joined already HOT 5
- Instance Level Load Balancing of a Subcriber in a PUB SUB Mode on the event bus HOT 1
- Export vert.x specific metrics when using Opentelemetry java agent. HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from vert.x.