Java Performance Tuning Cheatsheet
GC
Enable GC Log
-Xlog:gc*:file={file-path}
Print GC info
jstat -gc -t 11656 10000 30
jstat - Java Virtual Machine Statistics MonitoringTool
Analysis
Universal JVM GC analyzer - Java Garbage collection log analysis made easy
Thread
thread — Arthas 3.5.0 documentation
`-Xlog:thread+os:file=/tmp/threads.log`
Thread Pool
Java线程池实现原理及其在美团业务中的实践 - 美团技术团队
Tuning the Size of Your Thread Pool
Analysis
jstack.review - Java Thread Dump Analyzer
Smart Java thread dump analyzer - thread dump analysis in seconds
Heap
heapdump — Arthas 3.5.0 documentation
Analyze memory snapshots | IntelliJ IDEA
Analyze objects in the JVM heap | IntelliJ IDEA
Automatically heap dump when OOM
java -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=<file-or-dir-path>
Analysis
Eclipse Memory Analyzer Open Source Project | The Eclipse Foundation VisualVM: Home jhat - Java Heap Analysis Tool
References
Different Ways to Capture Java Heap Dumps | Baeldung
Non-Heap/Director Memory
CPU
Profiling tools | IntelliJ IDEA
Java VisualVM - Profiling Applications
HPROF: A Heap/CPU Profiling Tool
Frame Graph
火焰图/差分火焰图
Reference
JVM CPU Profiler技术原理及源码深度解析 - 美团技术团队
A Guide to Java Profilers | Baeldung
Stack Trace
Analyze external stack traces | IntelliJ IDEA
JVM
jvm — Arthas 3.5.0 documentation
Monitoring
Micrometer Application Monitoring
Micrometer: Spring Boot 2’s new application metrics collector
Logging
- Enable Async Logging - Chapter 4: Appenders - AsyncAppender
- Using trace id for every request
- Using global trace id for e2e trace
- Using sampling/throttling/rate limiting to limit the performance impact
End-to-end tracing
Jaeger: open source, end-to-end distributed tracing
Dynamic Tracing
trace — Arthas 3.5.0 documentation
Introduction - Dynamic Tracing Guide
Dynamic Tracing and Instrumentation
GitHub - btraceio/btrace: BTrace - a safe, dynamic tracing tool for the Java platform
Code Performance
monitor/watch/trace in Arthas
monitor — Arthas 3.5.0 documentation
Inspection
TCPDUMP/LIBPCAP public repository
Visualization
Grafana
Splunk
Kibana
Excel
echart
InfluxDB: Purpose-Built Open Source Time Series Database | InfluxData
Benchmarking
JMH
jmh/JMHSample_13_RunToRun.java at master · openjdk/jmh · GitHub
GitHub - artyushov/idea-jmh-plugin: Plugin for Itellij IDEA to make benchmarking with JMH easier.
Google Caliper
GitHub - google/caliper: Micro-benchmarking library for Java
Mocking
Mock Cassandra
GitHub - datastax/simulacron: Simulacron - An Apache Cassandra® Native Protocol Server Simulator
In-Memory Database
https://www.h2database.com/html/main.html
JIT Optimization
基本功 | Java即时编译器原理解析及实践 - 美团技术团队
Java on Steroids: 5 Super Useful JIT Optimization Techniques | OverOps
Performance Improvements via JIT Optimization | by Malith Jayasinghe | Medium
Just-in-time compilation - Wikipedia
Kubernetes Optimization
GitHub - kubernetes-sigs/metrics-server: Cluster-wide aggregator of resource usage data.
Prometheus - Monitoring system & time series database
Kubernetes Monitoring, Application Debug Platform | Pixie
Istio / Visualizing Metrics with Grafana
container_cpu_cfs_throttled_seconds_total
Linux Performance
USE Method: Linux Performance Checklist
CPU
Disk Usage
Memory Usage
Network IO Usage
File Descriptor
Network
ping
traceroute
iperf
Statistic
Avoid using average!! It lies!!
TP-based
Bucket
How to visualize Prometheus histograms in Grafana | Grafana Labs https://grafana.com/docs/grafana/latest/getting-started/intro-histograms/