The World of Java Optimisation By Holly Cummins
Creators:: Tradeoffs, Bad Science, and Polar Bears
Title:: The World of Java Optimisation By Holly Cummins
Date:: 2023-10-05
Source:: https://youtu.be/PvZaDo_I21g
Performance
performance can be:
- throughput
- transactions per second
- latency
- response time
- start-up time
- ramp-up time (warm-up)
- capacity
- network bandwidth
- memory usage
- CPU usage
- utilization
trade-offs:
- throughput vs. latency
- e.g. an optimization for more transactions per second may lead to a decrease of the start-up time
Frameworks & Runtimes
HotSpot vs. OpenJ9
Primary source: https://github.com/eclipse/openj9-website/blob/master/benchmark/daytrader7.md
→ OpenJ9 has a faster startup time and smaller memory footprint than HotSpot, however HotSpot has a higher throughput
GraalVM vs. OpenJDK
trading-off flexibility and throughput against startup speed and footprint
→ use GraalVM for ephemeral services or serverless
→ use OpenJDK for long running applications
Quarkus (OpenJDK) vs. Spring
- better startup time
- better footprint
- better throughput
- better developer experience
trade-offs:
- switch costs time and money
- not optimising for dynamism (nobody needs in the cloud)
How to optimize?
- measure and measure the right thing
- McNamara Fallacy: numbers are great, but they don't have to be helpful
- "Any improvements made anywhere besides the bottleneck are an illusion." — Gene Kim
- → you have to find the actual bottleneck
- example: running jmeter on the same machine or on a different machine?
- same machine: bottleneck is the CPU
- different machine: bottleneck is the network as the app gives a big speedup
- example: running jmeter on the same machine or on a different machine?
Tools
- method profiler:
- VisualVM
- Mission Control
- IntelliJ Profiler
- IBM Health Center (for OpenJ9)
- GC analysis
- GCMV
- heap analysis
- Eclipse MAT
- APM
- GlowRoot
- New Relic (not free)
- AppDynamics (not free)
- Dynatrace (not free)
- Distributed tracing
- Zipkin
- Jaeger
- Open Telemetry
Carbon
cost: leading indicator for carbon
performance: leading indicator for carbon
→ Quarkus cuts carbon by ~2-3x
→ native consumes more carbon than JVM