Skip to content

Instantly share code, notes, and snippets.

View vietj's full-sized avatar
🤖
Coding the Future

Julien Viet vietj

🤖
Coding the Future
View GitHub Profile
diff --git a/vertx-web-client/src/test/java/io/vertx/ext/web/client/WebClientTest.java b/vertx-web-client/src/test/java/io/vertx/ext/web/client/WebClientTest.java
index 4426909..11761b6 100644
--- a/vertx-web-client/src/test/java/io/vertx/ext/web/client/WebClientTest.java
+++ b/vertx-web-client/src/test/java/io/vertx/ext/web/client/WebClientTest.java
@@ -970,10 +970,10 @@ public class WebClientTest extends WebClientTestBase {
write(buffer, promise);
return promise.future();
}
- public void write(Buffer buffer, Handler<AsyncResult<Void>> handler) {
+ public void write(Buffer buffer, Promise<Void> promise) {
/*
* Copyright (c) 2011-2024 Contributors to the Eclipse Foundation
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0
* which is available at https://www.apache.org/licenses/LICENSE-2.0.
*
* SPDX-License-Identifier: EPL-2.0 OR Apache-2.0
*/
<!DOCTYPE html>
<html lang="en">
<head>
<title>Perflab results</title>
<style>
body {
font-family: monospace;
font-size: 12pt;
@Test
public void testPipeliningOrder() throws Exception {
client.close();
client = vertx.createHttpClient(createBaseClientOptions()
.setKeepAlive(true)
.setMaxPoolSize(1)
);
package org.creekservice.kafka.test.perf.performance;
public class Main {
public static void main(String[] args) throws Exception {
org.openjdk.jmh.Main.main(new String[]{
JsonValidateBenchmark.class.getName() + ".measureDraft_04_Vertx",
"-prof", "async:" +
"libPath=/Users/julien/java/async-profiler-2.9-macos/build/libasyncProfiler.dylib;" +

Vert.x Virtual Threads

Use virtual threads to write Vert.x code that looks like it is synchronous.

You still write the traditional Vert.x code processing events, but you have the opportunity to write synchronous code for complex workflows and use thread locals in such workflows.

Introduction

The non-blocking nature of Vert.x leads to asynchronous APIs. Asynchronous APIs can take various forms including callback style, promises or Rx-style. Vert.x uses futures in most places (although, it also supports Rx).

@vietj
vietj / vt.adoc
Last active October 24, 2023 07:35

Vert.x Virtual Threads

Use virtual threads to write Vert.x code that looks like it is synchronous.

You still write the traditional Vert.x code processing events, but you have the opportunity to write synchronous code for complex workflows and use thread locals in such workflows.

Introduction

One of the key advantages of Vert.x over many legacy application platforms is that it is almost entirely non-blocking (of kernel threads) - this allows it to handle a lot of concurrency (e.g. handle many connections, or messages) using a very small number of kernel threads, which allows it to scale very well.

@vietj
vietj / El Dogo.csv
Last active January 31, 2023 16:54
--- Tour 1 Tour 2 Tour 3 Tour 4 Tour 5
X=0 55.06% 30.22% 16.81% 9.21% 5.05%
X=1 0.00% 0.00% 0.00% 0.00% 0.03%
X=2 0.00% 0.00% 0.00% 0.18% 0.18%
X=3 0.00% 0.00% 0.98% 0.57% 0.39%
X=4 0.00% 5.88% 3.32% 2.18% 1.71%
X=5 34.30% 19.44% 10.67% 7.41% 4.36%
X=6 3.25% 1.83% 7.32% 5.48% 4.29%
X=7 0.31% 12.69% 9.63% 6.35% 5.56%
X=8 2.12% 14.58% 8.44% 8.81% 6.77%
@vietj
vietj / db.png
Last active February 1, 2024 03:09
Vert.x virtual thread benchmark
db.png
@vietj
vietj / index.html
Last active November 7, 2022 14:26
TFB 202-11-01 Json
<!DOCTYPE html>
<html lang="en">
<head>
<title>Perflab results</title>
<style>
body {
font-family: monospace;
font-size: 12pt;