Java Performance Tuning
Java(TM) - see bottom of page
Our valued sponsors who help make this site possible
JProfiler: Get rid of your performance problems and memory leaks!
Training online: Concurrency, Threading, GC, Advanced Java and more ...
Tips October 2026
|
JProfiler
|
|
Get rid of your performance problems and memory leaks!
|
|
JProfiler
|
|
Get rid of your performance problems and memory leaks!
|
|
|
Back to newsletter 311 contents
https://www.youtube.com/watch?v=H602ia22jmo
Java Concurrency Deep Dive: Threads, ExecutorService, CompletableFuture (Page last updated October 2026, Added 2026-10-27, Author BiharGeeks, Publisher BiharGeeks). Tips:
- Concurrency can only help when independent work can overlap.
- Cancel cooperatively with interrupts; rethrow InterruptedException or restore the interrupt flag.
- Prefer reusable thread pools over creating a platform thread per task.
- Use bounded queues, named threads, explicit rejection policies, and pool metrics.
- Use ThreadPoolExecutor.CallerRunsPolicy for backpressure or reject quickly with a clear 503.
- Size CPU-bound pools near the core count; estimate I/O pools with cores × (1 + wait/compute), then measure. Separate pools by dependency so one slow service cannot exhaust unrelated capacity.
- Avoid blocking I/O in parallel streams or the common ForkJoinPool.
- Always use timeouts with Future.get; unbounded waits can consume threads forever.
- Pass a dedicated executor to CompletableFuture asynchronous operations.
- Use thenApply for synchronous transformations and thenCompose for operations returning futures.
- Add both future-level and client-level timeouts; future timeouts do not stop underlying work.
- Clean up ThreadLocal values in finally to prevent data and security-context leakage.
- Monitor active threads, queue wait time, rejections, and p99 duration; use repeated thread dumps to diagnose stalls.
https://www.youtube.com/watch?v=8NURE3I4AJQ
High Performance Java Native AI with CUDA and the Vector API (Page last updated October 2026, Added 2026-10-27, Author Zoran Sevarac, Publisher Devoxx). Tips:
- Generate native bindings with `jextract` for the Foreign Function & Memory API; regenerate them whenever native-library versions change.
- Manage off-heap memory with scoped `Arena` blocks so they are released automatically. Restrict arenas to single-thread access unless shared access is genuinely required.
- Let the OS resolve native-library dependencies where possible, but account for platform-specific CUDA library names, locations, and dependencies. Validate compatibility among CUDA, cuDNN, GPU drivers, hardware, and generated bindings, prefer NVIDIA libraries such as cuBLAS and cuDNN over writing custom CUDA kernels.
- Hide pointers, memory transfers, and tensor layouts behind higher-level abstractions.
- Minimize CPU?GPU transfers; data movement is often the real GPU bottleneck.
- Use the Vector API for SIMD-friendly numerical loops, especially when datasets are too small to justify GPU overhead.
- Process arrays in vector-sized chunks, then handle remaining elements with a scalar loop.
- Benchmark with realistic model and dataset sizes; acceleration varies substantially by workload.
https://www.youtube.com/watch?v=xtz5bxyCpog
Java Secrets for Elegant Low Latency (Page last updated October 2026, Added 2026-10-27, Author Peter Lawrey, Publisher Today Software Magazine). Tips:
- Treat latency and throughput as functional requirements from the start.
- Define critical paths and measurable performance targets.
- Do as little work as necessary; remove accidental complexity and unused abstractions.
- Prefer architectural simplification over minor tuning, it can yield orders-of-magnitude gains.
- Measure tail latency (such as p99), not just averages.
- Monitor object-allocation rates even when garbage-collection pauses are low.
- Reduce allocations in multicore workloads; memory-bus saturation can prevent further scaling.
- Remember that allocation pressure affects the entire host, including other JVMs and virtual machines.
- Balance runtime optimization against developer productivity and maintenance cost.
- Record configuration and external data as events, to make production behavior reproducible.
- Normalize external protocols at system boundaries and use consistent internal event types.
- Keep tests deterministic by replacing current time and other variable inputs with fixed values.
- Selectively persist critical messages instead of persisting every event.
Jack Shirazi
Back to newsletter 311 contents
Last Updated: 2026-10-27
Copyright © 2000-2026 Fasterj.com. All Rights Reserved.
All trademarks and registered trademarks appearing on JavaPerformanceTuning.com are the property of their respective owners.
Java is a trademark or registered trademark of Oracle Corporation in the United States and other countries. JavaPerformanceTuning.com is not connected to Oracle Corporation and is not sponsored by Oracle Corporation.
URL: http://www.JavaPerformanceTuning.com/news/newtips311.shtml
RSS Feed: http://www.JavaPerformanceTuning.com/newsletters.rss
Trouble with this page? Please contact us