Parallel vs. Concurrent: G1's CPU Thread Allocation

`ParallelGCThreads` dictates the number of threads for Stop-The-World (STW) GC phases (e.g., Young GC, Mixed GC remark), while `ConcGCThreads` manages threads for concurrent tasks like marking. Increasing `ParallelGCThreads` can shorten STW pauses if CPU is abundant, improving latency, but too many can cause contention. Boosting `ConcGCThreads` can shorten concurrent cycles, reducing the chance of Full GCs, but adds CPU overhead for application threads.

The top 3

  1. G1 Parallel Threads: Default Count & STW Impact: The `-XX:ParallelGCThreads` flag controls the number of threads used for Stop-The-World (STW) phases like Young GC and Remark; its default is often 5/8 of logical processors for systems with over 8 cores, or the number of logical processors if 8 or fewer.
  2. G1 Concurrent Threads: Marking Efficiency vs. CPU Overhead: The `-XX:ConcGCThreads` flag, typically defaulting to 1/4 of `ParallelGCThreads`, controls the number of threads for concurrent marking, influencing how quickly marking completes versus the CPU resources consumed by the GC.
  3. G1 Thread Allocation: Latency vs. Throughput for ML: For low-latency ML applications, increasing `ParallelGCThreads` minimizes STW pauses, while high-throughput batch ML often benefits from balancing `ConcGCThreads` to reduce concurrent overhead and prevent full GCs.

Sources

Open the full topic