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.

The top 3

  1. Optimal MaxGCPauseMillis Targets for ML: For G1 GC in ML workloads, the default `MaxGCPauseMillis` is 200ms. For low-latency needs, targets between 50-100ms are common, while higher throughput applications might use 500ms or even 500-2000ms, though setting it too low can reduce efficiency.
  2. Top 3 G1 Flags Complementing Latency Targets: For achieving `MaxGCPauseMillis` goals, set `-Xms` and `-Xmx` to equal values to prevent heap resizing pauses, tune `InitiatingHeapOccupancyPercent` (IHOP) to start concurrent marking earlier for high allocation rates, and avoid explicitly setting young generation size (e.g., with `-Xmn`) to allow G1 to adaptively meet pause targets.
  3. Top 3 Reasons MaxGCPauseMillis Targets Fail: Common reasons G1 GC fails to meet `MaxGCPauseMillis` targets include insufficient heap space leading to evacuation failures, high object allocation rates preventing concurrent marking from completing in time, and excessive humongous objects causing heap fragmentation and longer pauses.

Sources

Open the full topic