Skip to content

Instantly share code, notes, and snippets.

View JohnTortugo's full-sized avatar
🎯
Focusing

Cesar Soares JohnTortugo

🎯
Focusing
View GitHub Profile
@JohnTortugo
JohnTortugo / gist:d8f87f92d8987b5da5c9e7898ce5f6ee
Created January 29, 2026 21:18
Substring Graal performance
==================== C2 ====================
openjdk version "25.0.2" 2026-01-20 LTS
OpenJDK Runtime Environment Corretto-25.0.2.10.1 (build 25.0.2+10-LTS)
OpenJDK 64-Bit Server VM Corretto-25.0.2.10.1 (build 25.0.2+10-LTS, mixed mode, sharing)
Java version: 25.0.2
String size: 10000
Substring length: 20
Iterations: 50000000
Total time: 756.349 ms
ns/op: 15.13
# Create project
mvn archetype:generate \
-DarchetypeGroupId=org.openjdk.jmh \
-DarchetypeArtifactId=jmh-java-benchmark-archetype \
-DarchetypeVersion=1.37 \
-DgroupId=com.jtortugo \
-DartifactId=TortugoBenchmark \
-Dversion=HEAD \
-DinteractiveMode=false
## # OSX useful installs
##
## brew install fzf
## $(brew --prefix)/opt/fzf/install
## brew install fd
## brew install ripgrep
##
## ----------------------------
## # Amazon Linux installs
##
@JohnTortugo
JohnTortugo / gist:0fceb5dc0b97cfd90ddf5e2bfea1328d
Created September 30, 2025 04:14
Command line to run GraalJS / GraalVM "mx benchmark"
mx --dy /compiler benchmark js-interop-jmh:JS_INTEROP_MICRO_BENCHMARKS -- --jvm=server --jvm-config=hosted -- -f 1 -w 1 -i 1
import org.graalvm.polyglot.Context;
import org.graalvm.polyglot.Engine;
import org.graalvm.polyglot.Source;
import org.graalvm.polyglot.Value;
import org.graalvm.polyglot.proxy.ProxyObject;
public class ProxyFieldAccess {
private static final int BENCH_ITERATIONS = 11000;
private static long[] times = new long[BENCH_ITERATIONS];
private static Double[] results = new Double[BENCH_ITERATIONS];
[2.701s][debug][codecache] Flushing nmethod 22/0x00007f71e9874a08, level=3, osr=0, cold=1, epoch=4, cold_count=2. Cache capacity: 7552Kb, free space: 13003Kb. method length
[2.701s][debug][codecache] Flushing nmethod 32/0x00007f71e9876288, level=3, osr=0, cold=1, epoch=4, cold_count=2. Cache capacity: 7552Kb, free space: 13003Kb. method map
[2.701s][debug][codecache] Flushing nmethod 72/0x00007f71e9925908, level=3, osr=0, cold=1, epoch=4, cold_count=2. Cache capacity: 7552Kb, free space: 13003Kb. method ensureCapacityInternal
[2.701s][debug][codecache] Flushing nmethod 137/0x00007f71e9adcd08, level=3, osr=0, cold=1, epoch=4, cold_count=2. Cache capacity: 7552Kb, free space: 13003Kb. method equals
[2.701s][debug][codecache] Flushing nmethod 118/0x00007f71e9add108, level=3, osr=0, cold=1, epoch=4, cold_count=2. Cache capacity: 7552Kb, free space: 13003Kb. method getShortUnaligned
[2.701s][debug][codecache] Flushing nmethod 109/0x00007f71e9adda88, level=3, osr=0, cold=1, epoch=4, cold_count=2. Cache capacity:
@JohnTortugo
JohnTortugo / gist:95e95ca4855854c658ea7374c63dd456
Created April 16, 2025 23:02
Patched nmethod::purge to print JVMCI method names
void nmethod::purge(bool free_code_cache_data, bool unregister_nmethod) {
assert(!free_code_cache_data, "must only call not freeing code cache data");
MutexLocker ml(CodeCache_lock, Mutex::_no_safepoint_check_flag);
// completely deallocate this method
const char* name = method()->name()->as_C_string();
const char* is_jvmci = "";
const char* is_osr = is_osr_method() ? "osr" : "";
const size_t code_cache_free_space = CodeCache::unallocated_capacity(CodeCache::get_code_blob_type(this))/1024;
@JohnTortugo
JohnTortugo / setup.sh
Last active July 20, 2025 03:12
Setup & Build OpenJDK on Ubuntu x64
#!/bin/bash
sudo apt install -y libcups2-dev libfontconfig1-dev
sudo apt install -y autoconf git make unzip zip
sudo apt install -y build-essential libasound2-dev
sudo apt-get install libx11-dev libxext-dev libxrender-dev libxrandr-dev libxtst-dev libxt-dev
sudo mkdir /wf/
sudo chgrp -R ec2-user /wf/
sudo chown -R ec2-user /wf/
@JohnTortugo
JohnTortugo / gist:80b55c549dc2484537cf25d02e8478b6
Created April 9, 2025 04:05
Compile & Run Java Test using WhiteBox & TestLib
/wf/tortugo-master/build/linux-x86_64-server-fastdebug/jdk/bin/javac -cp build/linux-x86_64-server-fastdebug/support/test/lib/test-lib.jar:/wf/tortugo-master/build/linux-x86_64-server-fastdebug/support/test/lib/wb_classes/ TestMethodEvictionAndProfiling.java
/wf/tortugo-master/build/linux-x86_64-server-fastdebug/jdk/bin/java \
-Xbootclasspath/a:/wf/tortugo-master/build/linux-x86_64-server-fastdebug/support/test/lib/wb_classes/ \
-cp .:/wf/tortugo-master/build/linux-x86_64-server-fastdebug/support/test/lib/test-lib.jar \
-XX:+UnlockDiagnosticVMOptions \
-XX:+WhiteBoxAPI \
-Xbatch \
-XX:+SegmentedCodeCache \
-XX:+UseG1GC \
@JohnTortugo
JohnTortugo / gist:87d5df2db4a96a9bc2a2b25f4d7fdb58
Last active November 14, 2025 23:33
Setup to build OpenJDK on Amazon Linux2
#!/bin/bash
sudo yum install -y alsa-lib-devel cups-devel fontconfig-devel
sudo yum install -y libXtst-devel libXt-devel libXrender-devel libXrandr-devel libXi-devel
sudo yum install -y autoconf git make
sudo yum groupinstall -y "Development Tools"
sudo mkdir /wf/
sudo chgrp -R ec2-user /wf/
sudo chown -R ec2-user /wf/