Profiling
- Profile first. A profiler: flight recorder, async-profiler: shows real hotspots; guessing optimises the wrong method.
- Benchmarks honestly. Microbenchmarks need JMH: warmup, forks and statistics: or the JIT makes your numbers fiction.
- Allocation profiling. Allocation pressure drives GC cost: profilers show which call sites create the garbage.
Memory and Concurrency Performance
- Escape analysis. The JIT can stack-allocate objects that never escape: clean small methods help it prove that.
- False sharing. Threads hammering neighbouring fields share a cache line: padding hot counters apart restores speed.
- Contention. Lock contention serialises your parallel code: shrink critical sections or shard the state.
JVM Tuning Fundamentals
- Heap sizing. Size the heap from measured live-set, not folklore: too small thrashes GC, too big wastes the host.
- Collector choice. Pick the collector by goal: throughput batch jobs and low-latency services want different ones.
- Measure in production. Tuning is empirical: change one flag, watch real latency percentiles, keep or revert.
Before and after this level
- Before: Level 13: Modern Java: Records and Pattern Matching, Modern Language Features, Writing Idiomatic Current Java.
- Next: Level 15: Production Java: Modules, Builds and Dependencies, Logging, Configuration and Reliability, Production Application Design.
In the app each of these ideas is taught and then asked back, and the level ends with a checkpoint and flashcards. See Checkpoints and flashcards.
Frequently asked questions
What does Java Level 14: Performance cover?
Profiling, Memory and Concurrency Performance, JVM Tuning Fundamentals: 3 lessons and 9 ideas.
What should I know before this level?
The level before it, Level 13: Modern Java, which covers Records and Pattern Matching, Modern Language Features, Writing Idiomatic Current Java.