Top 3 G1 Tuning Flags for ML Performance

For optimal G1 performance in ML, prioritize three JVM flags: Use `-XX:MaxGCPauseMillis` (e.g., 200ms) to set a pause time goal, set `-Xms` and `-Xmx` to equal values (e.g., `-Xms4g -Xmx4g`) to prevent heap resizing, and adjust `-XX:InitiatingHeapOccupancyPercent` (IHOP) to control when concurrent marking begins.

The top 3

  1. Optimize Latency: MaxGCPauseMillis Target for ML: The `-XX:MaxGCPauseMillis` flag sets a soft target for G1 GC pause times, with a default of 200ms. For latency-sensitive ML applications, reducing this (e.g., to 100ms) can minimize stop-the-world events, though it may lead to more frequent, shorter collections and potentially affect throughput. G1 dynamically adjusts the young generation size to try and meet this pause goal.
  2. Prevent Full GCs: IHOP Threshold for Stable Throughput: The `-XX:InitiatingHeapOccupancyPercent` (IHOP) flag, defaulting to 45%, dictates when G1 starts its concurrent marking phase. Lowering this value (e.g., to 30-35% for high allocation rates) initiates marking earlier, providing more time for the concurrent cycle to complete and significantly reducing the risk of a costly Full GC, which can severely impact ML application throughput. Java 9+ features Adaptive IHOP, where G1 automatically adjusts this threshold.
  3. Boost Throughput: ParallelGCThreads for Faster Collection: The `-XX:ParallelGCThreads` flag controls the number of parallel worker threads used during G1's stop-the-world GC pauses. Increasing this value can significantly improve collection speed and overall application throughput, vital for performance-intensive ML tasks on multi-core systems.

Sources

Open the full topic