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

Weird ASM produced around type guards

With

# VM version: JDK 17.0.7, Java HotSpot(TM) 64-Bit Server VM, 17.0.7+8-LTS-224

red.hat.puzzles.polymorphism.InstanceOfScalabilityBenchmark.encodeFullType -pencoderType=a -ppollutionCases=20000 -t 16 -f 4 -prof perfasm

where

Benchmark (same) (size) Mode Cnt Score Error Units
LowerCaseComparison.optimizedContentEqualsIgnoreCase true 8 avgt 10 6.896 ± 0.163 ns/op
LowerCaseComparison.optimizedContentEqualsIgnoreCase:CPI true 8 avgt 0.240 clks/insn
LowerCaseComparison.optimizedContentEqualsIgnoreCase:IPC true 8 avgt 4.161 insns/clk
LowerCaseComparison.optimizedContentEqualsIgnoreCase:L1-dcache-load-misses true 8 avgt 0.007 #/op
LowerCaseComparison.optimizedContentEqualsIgnoreCase:L1-dcache-loads true 8 avgt 36.741 #/op
LowerCaseComparison.optimizedContentEqualsIgnoreCase:L1-icache-load-misses true 8 avgt ≈ 10⁻³ #/op
LowerCaseComparison.optimizedContentEqualsIgnoreCase:L1-icache-loads
============================= C2-compiled nmethod ==============================
----------------------------------- Assembly -----------------------------------
Compiled method (c2) 1259 774 4 red.hat.puzzles.checks.LowerCaseComparison::optimizedContentEqualsIgnoreCase (12 bytes)
total in heap [0x00007f06e5229690,0x00007f06e522a3a0] = 3344
relocation [0x00007f06e52297f0,0x00007f06e5229818] = 40
main code [0x00007f06e5229820,0x00007f06e5229be0] = 960
stub code [0x00007f06e5229be0,0x00007f06e5229bf8] = 24
oops [0x00007f06e5229bf8,0x00007f06e5229c00] = 8
metadata [0x00007f06e5229c00,0x00007f06e5229c30] = 48
============================= C2-compiled nmethod ==============================
----------------------------------- Assembly -----------------------------------
Compiled method (c2) 204 763 4 red.hat.puzzles.checks.LowerCaseComparison::unoptimizedContentEqualsIgnoreCase (12 bytes)
total in heap [0x00007f0279223e90,0x00007f0279224bd8] = 3400
relocation [0x00007f0279223ff0,0x00007f0279224018] = 40
main code [0x00007f0279224020,0x00007f0279224420] = 1024
stub code [0x00007f0279224420,0x00007f0279224438] = 24
oops [0x00007f0279224438,0x00007f0279224440] = 8
metadata [0x00007f0279224440,0x00007f0279224478] = 56
package red.hat.puzzles.concurrent;
import org.openjdk.jmh.annotations.Benchmark;
import org.openjdk.jmh.annotations.BenchmarkMode;
import org.openjdk.jmh.annotations.CompilerControl;
import org.openjdk.jmh.annotations.Fork;
import org.openjdk.jmh.annotations.Measurement;
import org.openjdk.jmh.annotations.Mode;
import org.openjdk.jmh.annotations.OutputTimeUnit;
import org.openjdk.jmh.annotations.Scope;
package red.hat.puzzles.http;
import org.openjdk.jmh.annotations.Benchmark;
import org.openjdk.jmh.annotations.BenchmarkMode;
import org.openjdk.jmh.annotations.CompilerControl;
import org.openjdk.jmh.annotations.Fork;
import org.openjdk.jmh.annotations.Measurement;
import org.openjdk.jmh.annotations.Mode;
import org.openjdk.jmh.annotations.OutputTimeUnit;
import org.openjdk.jmh.annotations.Scope;
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"