Skip to content

Instantly share code, notes, and snippets.

View franz1981's full-sized avatar
🏠
Working from home

Francesco Nigro franz1981

🏠
Working from home
View GitHub Profile
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
public class Main {
static {
System.out.println("here we go...");
try (ExecutorService executor = Executors.newVirtualThreadPerTaskExecutor()) {
executor.submit(() -> {}).get();
} catch (Exception e) {
@franz1981
franz1981 / ClientMessageAPI.java
Created October 1, 2023 07:41
grpc-examples Low level Vertx Message API
package io.vertx.example.grpc.helloworld;
import com.google.protobuf.Message;
import com.google.protobuf.Struct;
import com.google.protobuf.util.JsonFormat;
import io.vertx.core.AbstractVerticle;
import io.vertx.core.Future;
import io.vertx.core.Launcher;
import io.vertx.core.buffer.Buffer;
import io.vertx.core.net.SocketAddress;
/*
* Copyright 2021 Andrei Pangin
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
@franz1981
franz1981 / startup.sh
Created September 18, 2023 16:10
Dummy script for startup
#!/bin/bash
if [ $# -ne 2 ]; then
echo "Usage: $0 <application> <N>"
exit 1
fi
application="$1"
N="$2"
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.Executor;
import java.util.concurrent.Executors;
public class VThreadCreation {
private static final int TASKS = 1024;
public static void main(String[] args) throws InterruptedException {
long rounds = Long.MAX_VALUE;
if (args.length == 1) {
package red.hat.puzzles.concurrent;
import org.openjdk.jmh.annotations.*;
import org.openjdk.jmh.infra.Blackhole;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.Executor;
import java.util.concurrent.Executors;
@State(Scope.Benchmark)
#!/bin/bash
wrk -H 'Host: localhost' -H 'Accept: application/json,text/html;q=0.9,application/xhtml+xml;q=0.9,application/xml;q=0.8,*/*;q=0.7' -H 'Connection: keep-alive' --latency -d 5 -c 8 --timeout 8 -t 8 http://localhost:8080/db
wrk -H 'Host: localhost' -H 'Accept: application/json,text/html;q=0.9,application/xhtml+xml;q=0.9,application/xml;q=0.8,*/*;q=0.7' -H 'Connection: keep-alive' --latency -d 15 -c 512 --timeout 8 -t 64 "http://localhost:8080/db"
wrk -H 'Host: localhost' -H 'Accept: application/json,text/html;q=0.9,application/xhtml+xml;q=0.9,application/xml;q=0.8,*/*;q=0.7' -H 'Connection: keep-alive' --latency -d 15 -c 16 --timeout 8 -t 16 "http://localhost:8080/db"
wrk -H 'Host: localhost' -H 'Accept: application/json,text/html;q=0.9,application/xhtml+xml;q=0.9,application/xml;q=0.8,*/*;q=0.7' -H 'Connection: keep-alive' --latency -d 15 -c 32 --timeout 8 -t 32 "http://localhost:8080/db"
wrk -H 'Host: localhost' -H 'Accept: application/json,text/html;q=0.9,application/xhtml+xml;q=0.9,applicat
package red.hat.puzzles.concurrent;
import org.openjdk.jmh.annotations.*;
import org.openjdk.jmh.infra.Blackhole;
import java.lang.invoke.MethodHandles;
import java.lang.invoke.VarHandle;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicLongFieldUpdater;
Hottest code regions (>10.00% "cycles" events):
....[Hottest Region 1]..............................................................................
c2, level 4, java.lang.invoke.VarHandleLongs$FieldInstanceReadWrite::setVolatile, version 767 (0 bytes)
0x00007fdf24a22f4e: add %rcx,%rsi
0x00007fdf24a22f51: mov (%rsi,%r11,1),%r11
0x00007fdf24a22f55: cmp %r11,%rax
╭ 0x00007fdf24a22f58: jne 0x00007fdf24a22f7b ;*invokevirtual putLongVolatile {reexecute=0 rethrow=0 return_oop=0}
│ ; - java.lang.invoke.VarHandleLongs$FieldInstanceReadWrite::setVolatile@27 (line 154)
private static final int NOT_ASCII = 128;
private static final boolean[] RESERVED = new boolean[256];
static {
final int[] reservedChars = new int[] {'+', '#', '/', ';', '?', '&', ' ', '!', '=', '$', '|', '*', ':', '~', '-'};
for (int c : reservedChars) {
RESERVED[c] = true;
}
assert !RESERVED[NOT_ASCII];
}