Skip to content

Instantly share code, notes, and snippets.

View alex-dukhno's full-sized avatar
📚
research in progress

Alexander Dukhno alex-dukhno

📚
research in progress
View GitHub Profile

Quick Tips for Fast Code on the JVM

I was talking to a coworker recently about general techniques that almost always form the core of any effort to write very fast, down-to-the-metal hot path code on the JVM, and they pointed out that there really isn't a particularly good place to go for this information. It occurred to me that, really, I had more or less picked up all of it by word of mouth and experience, and there just aren't any good reference sources on the topic. So… here's my word of mouth.

This is by no means a comprehensive gist. It's also important to understand that the techniques that I outline in here are not 100% absolute either. Performance on the JVM is an incredibly complicated subject, and while there are rules that almost always hold true, the "almost" remains very salient. Also, for many or even most applications, there will be other techniques that I'm not mentioning which will have a greater impact. JMH, Java Flight Recorder, and a good profiler are your very best friend! Mea

Index: jmh/jmh-core/src/main/java/org/openjdk/jmh/util/Utils.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- jmh/jmh-core/src/main/java/org/openjdk/jmh/util/Utils.java (revision 1434:1ddf31f810a3100b9433c3fedf24615e85b1d1a7)
+++ jmh/jmh-core/src/main/java/org/openjdk/jmh/util/Utils.java (revision 1434+:1ddf31f810a3+)
@@ -446,6 +446,31 @@
return messages;
}
@lattner
lattner / TaskConcurrencyManifesto.md
Last active April 26, 2026 13:51
Swift Concurrency Manifesto
@djg
djg / reading-list.md
Last active March 21, 2025 08:41
Fabian's Recommened Reading List
cmake_minimum_required(VERSION 3.6)
project(hotspot)
set(CMAKE_CXX_STANDARD 98)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D_GNU_SOURCE \
-D_REENTRANT \
-DLINUX -DINCLUDE_SUFFIX_OS=_linux -DVM_LITTLE_ENDIAN \
-DTARGET_COMPILER_gcc \
-DAMD64 -DHOTSPOT_LIB_ARCH='amd64' -DINCLUDE_SUFFIX_CPU=_x86 -D_LP64 -DTARGET_ARCH_x86 \
-DCOMPILER1 -DCOMPILER2")
@alanpeabody
alanpeabody / my_app.ex
Last active February 19, 2025 16:29
Websockets in Elixir with Cowboy and Plug
defmodule MyApp do
use Application
def start(_type, _args) do
import Supervisor.Spec, warn: false
children = [
Plug.Adapters.Cowboy.child_spec(:http, MyApp.Router, [], [
dispatch: dispatch
])
@maxd
maxd / modena.css
Last active September 17, 2025 06:58
modena.css from JDK 10.0.1
/*
* Copyright (c) 2009, 2017, Oracle and/or its affiliates. All rights reserved.
* ORACLE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
*
*
*
*
*
*
*
@zsup
zsup / ddd.md
Last active May 7, 2026 13:43
Documentation-Driven Development (DDD)

Documentation-Driven Development

The philosophy behind Documentation-Driven Development is a simple: from the perspective of a user, if a feature is not documented, then it doesn't exist, and if a feature is documented incorrectly, then it's broken.

  • Document the feature first. Figure out how you're going to describe the feature to users; if it's not documented, it doesn't exist. Documentation is the best way to define a feature in a user's eyes.
  • Whenever possible, documentation should be reviewed by users (community or Spark Elite) before any development begins.
  • Once documentation has been written, development should commence, and test-driven development is preferred.
  • Unit tests should be written that test the features as described by the documentation. If the functionality ever comes out of alignment with the documentation, tests should fail.
  • When a feature is being modified, it should be modified documentation-first.
  • When documentation is modified, so should be the tests.
@matteobertozzi
matteobertozzi / psql-srv.py
Created November 27, 2013 05:17
postgres "server" wire protocol example
# th30z@u1310:[Desktop]$ psql -h localhost -p 55432
# Password:
# psql (9.1.10, server 0.0.0)
# WARNING: psql version 9.1, server version 0.0.
# Some psql features might not work.
# Type "help" for help.
#
# th30z=> select foo;
# a | b
# ---+---
@myronmarston
myronmarston / explanation.md
Last active October 22, 2020 18:16
Explanation for why `its` will be removed from rspec-3

its isn't core to RSpec. One the of the focuses of RSpec is on the documentation aspects of tests. Unfortunately, its often leads to documentation output that is essentially lies. Consider this spec:

User = Struct.new(:name, :email)

describe User do
  subject { User.new("bob") }
  its(:name) { should == "bob" }
end