Vert.x virtual threads incubator

Overview

Vert.x Virtual Threads Incubator

Build Status

Incubator for virtual threads based prototypes.

Prerequisites

Projects

Usage

enable preview flag must be enabled

<build>
  <pluginManagement>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
        <configuration>
          <release>19</release>
          <compilerArgs>--enable-preview</compilerArgs>
        </configuration>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-surefire-plugin</artifactId>
        <configuration>
          <argLine>--enable-preview</argLine>
        </configuration>
      </plugin>
    </plugins>
  </pluginManagement>
</build>

snapshots are available at s01.oss.sonatype.org

  <repositories>
  <repository>
    <id>vertx-snapshots-repository</id>
    <name>Vert.x Snapshots Repository</name>
    <url>https://s01.oss.sonatype.org/content/repositories/snapshots/</url>
    <releases>
      <enabled>false</enabled>
    </releases>
    <snapshots>
      <enabled>true</enabled>
    </snapshots>
  </repository>
</repositories>
Comments
  • executeBlock / blockingHandler support with virtual threads

    executeBlock / blockingHandler support with virtual threads

    Describe the feature

    Extend existing async/await support to executeBlocking / blockingHandler threads

    Use cases

    Performance uplift (in theory) for any existing executeBlocking / blockingHandler code implementation in microthreads

    Contribution

    Who should implement this feature ? are you volunteering for implementing this feature or do you know that is able and willing implement this feature ?

    I dunno who should, or is willing to implement this feature

    enhancement 
    opened by PicoCreator 0
  • Completed futures should not park

    Completed futures should not park

    Motivation:

    Already completed futures should not park the thread. Currently, they do. This can improve performance.

    This also resolves an ordering issue in the default event loop context.

    opened by doctorpangloss 0
  • java.lang.NullPointerException in EventLoopScheduler

    java.lang.NullPointerException in EventLoopScheduler

    Version

    947f181

    Context

    I observed the following while load testing a complex application. The core part of this load test runs many SQL transactions. These transactions are implemented as awaiting Vertx JOOQ reactive client executing a SQL query against a PgPool.

    java.lang.NullPointerException: Cannot invoke "java.lang.Runnable.run()" because the return value of "java.util.LinkedList.poll()" is null
    	at io.vertx.await.impl.EventLoopScheduler.lambda$new$1(EventLoopScheduler.java:75)
    	at io.vertx.await.impl.EventLoopScheduler.lambda$new$0(EventLoopScheduler.java:60)
    	at io.vertx.await.impl.EventLoopScheduler.lambda$new$2(EventLoopScheduler.java:74)
    	at java.base/java.lang.VirtualThread.submitRunContinuation(VirtualThread.java:234)
    	at java.base/java.lang.VirtualThread.submitRunContinuation(VirtualThread.java:253)
    	at java.base/java.lang.VirtualThread.start(VirtualThread.java:462)
    	at java.base/java.lang.VirtualThread.start(VirtualThread.java:475)
    	at io.vertx.await.impl.EventLoopScheduler.execute(EventLoopScheduler.java:89)
    	at io.vertx.await.impl.VirtualThreadContext.execute2(VirtualThreadContext.java:118)
    	at io.vertx.await.impl.VirtualThreadContext.execute(VirtualThreadContext.java:67)
    	at io.vertx.await.impl.VirtualThreadContext.execute(VirtualThreadContext.java:84)
    	at io.vertx.core.impl.ContextBase.execute(ContextBase.java:225)
    	at io.vertx.core.impl.future.FutureBase.emitSuccess(FutureBase.java:51)
    	at io.vertx.core.impl.future.FutureImpl.tryComplete(FutureImpl.java:211)
    	at io.vertx.core.impl.future.PromiseImpl.tryComplete(PromiseImpl.java:23)
    	at io.vertx.core.impl.future.PromiseImpl.onSuccess(PromiseImpl.java:49)
    	at io.vertx.core.impl.future.PromiseImpl.handle(PromiseImpl.java:41)
    	at io.vertx.core.impl.future.PromiseImpl.handle(PromiseImpl.java:23)
    	at io.vertx.sqlclient.impl.command.CommandResponse.fire(CommandResponse.java:46)
    	at io.vertx.sqlclient.impl.SocketConnectionBase.handleMessage(SocketConnectionBase.java:292)
    	at io.vertx.pgclient.impl.PgSocketConnection.handleMessage(PgSocketConnection.java:97)
    	at io.vertx.sqlclient.impl.SocketConnectionBase.lambda$init$0(SocketConnectionBase.java:105)
    	at io.vertx.core.impl.EventLoopContext.emit(EventLoopContext.java:55)
    	at io.vertx.core.impl.ContextBase.emit(ContextBase.java:239)
    	at io.vertx.core.net.impl.NetSocketImpl.handleMessage(NetSocketImpl.java:390)
    	at io.vertx.core.net.impl.ConnectionBase.read(ConnectionBase.java:157)
    	at io.vertx.core.net.impl.VertxHandler.channelRead(VertxHandler.java:153)
    	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:442)
    	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:420)
    	at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:412)
    	at io.netty.channel.CombinedChannelDuplexHandler$DelegatingChannelHandlerContext.fireChannelRead(CombinedChannelDuplexHandler.java:436)
    	at io.vertx.pgclient.impl.codec.PgEncoder.lambda$write$0(PgEncoder.java:98)
    	at io.vertx.pgclient.impl.codec.PgCommandCodec.handleReadyForQuery(PgCommandCodec.java:139)
    	at io.vertx.pgclient.impl.codec.PgDecoder.decodeReadyForQuery(PgDecoder.java:237)
    	at io.vertx.pgclient.impl.codec.PgDecoder.channelRead(PgDecoder.java:96)
    	at io.netty.channel.CombinedChannelDuplexHandler.channelRead(CombinedChannelDuplexHandler.java:251)
    	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:442)
    	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:420)
    	at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:412)
    	at io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1410)
    	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:440)
    	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:420)
    	at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:919)
    	at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:166)
    	at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:788)
    	at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:724)
    	at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:650)
    	at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:562)
    	at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:997)
    	at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
    	at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
    	at java.base/java.lang.Thread.run(Thread.java:1589)
    

    For your convenience, the context of this code is: https://github.com/vert-x3/vertx-virtual-threads-incubator/blob/947f1812290f0c3cc357d834f62ab24e620b4c1f/vertx-async-await-incubator/src/main/java/io/vertx/await/impl/EventLoopScheduler.java#L75

    I observed this issue again in load testing, now within a gRPC stub implementation:

    Dec 22, 2022 4:32:39 PM io.grpc.internal.SerializingExecutor run
    SEVERE: Exception while executing runnable io.grpc.internal.ServerImpl$JumpToApplicationThreadServerStreamListener$1MessagesAvailable@3600a37f
    java.lang.NullPointerException: Cannot invoke "java.lang.Runnable.run()" because the return value of "java.util.LinkedList.poll()" is null
    	at io.vertx.await.impl.EventLoopScheduler.lambda$new$1(EventLoopScheduler.java:75)
    	at io.vertx.await.impl.EventLoopScheduler.lambda$new$0(EventLoopScheduler.java:60)
    	at io.vertx.await.impl.EventLoopScheduler.lambda$new$2(EventLoopScheduler.java:74)
    	at java.base/java.lang.VirtualThread.submitRunContinuation(VirtualThread.java:234)
    	at java.base/java.lang.VirtualThread.submitRunContinuation(VirtualThread.java:253)
    	at java.base/java.lang.VirtualThread.start(VirtualThread.java:462)
    	at java.base/java.lang.VirtualThread.start(VirtualThread.java:475)
    	at io.vertx.await.impl.EventLoopScheduler.execute(EventLoopScheduler.java:89)
    	at io.vertx.core.eventbus.impl.HandlerRegistration.receive(HandlerRegistration.java:46)
    	at io.vertx.core.eventbus.impl.EventBusImpl.deliverMessageLocally(EventBusImpl.java:375)
    	at io.vertx.core.eventbus.impl.EventBusImpl.sendLocally(EventBusImpl.java:341)
    	at io.vertx.core.eventbus.impl.EventBusImpl.sendOrPub(EventBusImpl.java:329)
    	at io.vertx.core.eventbus.impl.OutboundDeliveryContext.execute(OutboundDeliveryContext.java:109)
    	at io.vertx.core.eventbus.impl.DeliveryContextBase.next(DeliveryContextBase.java:72)
    	at io.vertx.core.eventbus.impl.OutboundDeliveryContext.next(OutboundDeliveryContext.java:28)
    	at io.vertx.core.eventbus.impl.EventBusImpl.sendOrPubInternal(EventBusImpl.java:422)
    	at io.vertx.core.eventbus.impl.EventBusImpl.sendOrPubInternal(EventBusImpl.java:428)
    	at io.vertx.core.eventbus.impl.EventBusImpl.publish(EventBusImpl.java:164)
    // context: this is forwarding grpc messages to the event bus
    	at com.hiddenswitch.framework.impl.ServerGameContext.clientToServer(ServerGameContext.java:281)
    	at com.hiddenswitch.framework.impl.ServerGameContext.lambda$subscribeGame$3(ServerGameContext.java:271)
    // end context
    	at io.vertx.grpc.stub.StreamObserverReadStream.onNext(StreamObserverReadStream.java:37)
    	at io.grpc.stub.ServerCalls$StreamingServerCallHandler$StreamingServerCallListener.onMessage(ServerCalls.java:262)
    	at io.grpc.ForwardingServerCallListener.onMessage(ForwardingServerCallListener.java:33)
    	at io.grpc.Contexts$ContextualizedServerCallListener.onMessage(Contexts.java:76)
    	at com.avast.grpc.jwt.server.DelayedServerCallListener.onMessage(DelayedServerCallListener.java:17)
    	at io.grpc.ForwardingServerCallListener.onMessage(ForwardingServerCallListener.java:33)
    	at com.be_hase.grpc.micrometer.MicrometerServerCallListener.onMessage(MicrometerServerCallListener.java:22)
    	at io.grpc.ForwardingServerCallListener.onMessage(ForwardingServerCallListener.java:33)
    	at io.grpc.Contexts$ContextualizedServerCallListener.onMessage(Contexts.java:76)
    	at io.grpc.ForwardingServerCallListener.onMessage(ForwardingServerCallListener.java:33)
    	at io.opentracing.contrib.grpc.TracingServerInterceptor$2.onMessage(TracingServerInterceptor.java:221)
    	at io.grpc.internal.ServerCallImpl$ServerStreamListenerImpl.messagesAvailableInternal(ServerCallImpl.java:318)
    	at io.grpc.internal.ServerCallImpl$ServerStreamListenerImpl.messagesAvailable(ServerCallImpl.java:301)
    	at io.grpc.internal.ServerImpl$JumpToApplicationThreadServerStreamListener$1MessagesAvailable.runInContext(ServerImpl.java:834)
    	at io.grpc.internal.ContextRunnable.run(ContextRunnable.java:37)
    	at io.grpc.internal.SerializingExecutor.run(SerializingExecutor.java:133)
    	at io.vertx.grpc.VertxServer$ActualServer.lambda$null$0(VertxServer.java:96)
    	at io.vertx.core.impl.ContextInternal.dispatch(ContextInternal.java:264)
    	at io.vertx.core.impl.ContextInternal.dispatch(ContextInternal.java:246)
    	at io.vertx.core.impl.EventLoopContext.lambda$runOnContext$0(EventLoopContext.java:43)
    	at io.netty.util.concurrent.AbstractEventExecutor.runTask(AbstractEventExecutor.java:174)
    	at io.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java:167)
    	at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:470)
    	at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:566)
    	at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:997)
    	at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
    	at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
    	at java.base/java.lang.Thread.run(Thread.java:1589)
    

    Do you have a reproducer?

    (Investigating)

    Steps to reproduce

    (Investigating)

    Extra

    macOS 13, Java 19

    bug 
    opened by doctorpangloss 4
  • Thread interruption investigation (fixes needed)

    Thread interruption investigation (fixes needed)

    These tests show that Thread.currentThread().isInterrupted() doesn't get set to true, as expected, when a virtual thread is interrupted in Vertx.

    Additionally, the DefaultVirtualThreadContextTest cannot interrupt Thread.Sleep(), but it's not clear to me if the reason is expected.

    opened by doctorpangloss 1
  • Allow appending items to existing leafs, like before

    Allow appending items to existing leafs, like before

    Signed-off-by: Paulo Lopes [email protected]

    Motivation:

    This is a first step to allow mutating the internals of the router, which will later allow add the concept of filters

    opened by pmlopes 0
Owner
Eclipse Vert.x
Eclipse Vert.x
BlackBox is a virtual engine, it can clone and run virtual application on Android

BlackBox is a virtual engine, it can clone and run virtual application on Android, users don't have to install APK file to run the application on devices. BlackBox control all virtual applications, so you can do anything you want by using BlackBox.

null 1.6k Jan 3, 2023
Duel Threads - Concurrency techniques duel it out for the championship (and bragging rights)

Duel Threads Concurrency techniques duel it out for the championship (and bragging rights) Phases: Argue over rules, challenges and the grand prize Se

Jason Sipula 2 May 9, 2022
A virtual camera based on Xposed

A virtual camera based on Xposed

null 643 Dec 31, 2022
LimboAuth - Minecraft Auth System for Velocity proxy built in virtual server (Limbo).

LimboAuth Auth System built in virtual server (Limbo). MC-Market SpigotMC.org Описание и обсуждение на русском языке (spigotmc.ru) Описание и обсужден

Elytrium 89 Jan 4, 2023
Runtime code generation for the Java virtual machine.

Byte Buddy runtime code generation for the Java virtual machine Byte Buddy is a code generation and manipulation library for creating and modifying Ja

Rafael Winterhalter 5.3k Dec 27, 2022
A fast and secure browser for standalone virtual-reality and augmented-reality headsets.

Wolvic VR Browser The goal of the Wolvic project is to create a full-featured browser exclusively for standalone AR and VR headsets. You can find us i

Igalia 465 Jan 7, 2023
Virtual model of an atom

Project Zero Virtual model of an atom. Download Demo · Report Bug Table of Contents About The Project Built With Getting Started Prerequisites Install

Phi Long Bui 3 Dec 23, 2022
Java virtual machine made in Java by HoverCatz#0060

Obzcure Virtual Machine Java virtual machine made in Java THIS IS NOT PRODUCTION SAFE - WORK IN PROGRESS! Use at your own risk. Requires Java 17 (with

null 9 Oct 18, 2022
code test from a virtual bank

account-manager provided 2 apis: /api/account/{accountNumber} for retrieving balance /api/account/transfer for transferring balance transfer balance o

Ray Chong 2 Oct 23, 2021
Echo client-server components to evaluate Project Loom virtual threads.

Overview Project Loom is the OpenJDK initiative to introduce user-mode threads in Java. The purpose of this repository is to compare Project Loom virt

Elliot Barlas 15 Nov 1, 2022
A Java Virtual Machine - running on a Java Virtual Machine - running on a (jk).

Javaception A Java Virtual Machine - running on a Java Virtual Machine - running on a (jk). Goals JVMS compliant Java Virtual Machine Somewhat fast Re

null 33 Oct 10, 2022
BlackBox is a virtual engine, it can clone and run virtual application on Android

BlackBox is a virtual engine, it can clone and run virtual application on Android, users don't have to install APK file to run the application on devices. BlackBox control all virtual applications, so you can do anything you want by using BlackBox.

null 1.6k Jan 3, 2023
A high performance replicated log service. (The development is moved to Apache Incubator)

Apache DistributedLog (incubating) Apache DistributedLog (DL) is a high-throughput, low-latency replicated log service, offering durability, replicati

Twitter 2.2k Dec 29, 2022
Hadoop library for large-scale data processing, now an Apache Incubator project

Apache DataFu Follow @apachedatafu Apache DataFu is a collection of libraries for working with large-scale data in Hadoop. The project was inspired by

LinkedIn's Attic 589 Apr 1, 2022
This code base is retained for historical interest only, please visit Apache Incubator Repo for latest one

Apache Kylin Apache Kylin is an open source Distributed Analytics Engine to provide SQL interface and multi-dimensional analysis (OLAP) on Hadoop supp

Kylin OLAP Engine 561 Dec 4, 2022
Event bus for Android and Java that simplifies communication between Activities, Fragments, Threads, Services, etc. Less code, better quality.

EventBus EventBus is a publish/subscribe event bus for Android and Java. EventBus... simplifies the communication between components decouples event s

Markus Junginger 24.2k Jan 3, 2023
Lightweight threads for Java, with message passing, nio, http and scheduling support.

Kilim: Continuations, Fibers, Actors and message passing for the JVM

Sriram Srinivasan 1.7k Jan 3, 2023
Duel Threads - Concurrency techniques duel it out for the championship (and bragging rights)

Duel Threads Concurrency techniques duel it out for the championship (and bragging rights) Phases: Argue over rules, challenges and the grand prize Se

Jason Sipula 2 May 9, 2022
Vert.x is a tool-kit for building reactive applications on the JVM

Vert.x Core This is the repository for Vert.x core. Vert.x core contains fairly low-level functionality, including support for HTTP, TCP, file system

Eclipse Vert.x 13.3k Jan 8, 2023
Vert.x jOOQ DSL

jOOQ.x - Vertx jOOQ DSL jooqx leverages the power of typesafe SQL from jOOQ DSL and running on SQL connection in a reactive and non-blocking of SQL dr

zero88 18 Nov 16, 2022