JDK-8357296 : G1 GC: Implement Core AHS Control Loop Components
  • Type: Sub-task
  • Component: hotspot
  • Sub-Component: gc
  • Priority: P3
  • Status: New
  • Resolution: Unresolved
  • Submitted: 2025-05-20
  • Updated: 2025-05-20
Description
Implements core components of the G1 Adaptive/Automatic Heap Sizing (G1-AHS) control loop based on CPU time feedback. This enhancement adds a feedback-based control system that automatically adjusts heap size based on GC overhead and application behavior.

Key Features:
1. CPU-time based Control Loop:
   - Target GC CPU ratio from GCTimeRatio
   - Configurable damping factor (α) for stability
   - SoftMaxHeapSize support with 25% CPU cap

2. Memory Pressure Management:
   - GC thrashing detection (>25% overhead)
   - Adaptive heap growth during thrashing with high mutator activity
   - Hysteresis for uncommit decisions
   - Reserve space management

3. Workload Analytics:
   - Tracks mutator CPU usage with moving average
   - Monitors GC overhead trends
   - Adjusts heap target based on workload characteristics

4. Marking Integration:
   - IHOP threshold coordination
   - Marking cycle awareness
   - SoftMax-aware threshold updates
   - Concurrent marking synchronization

Implementation Strategy: Core Control Loop:
   - Heap target computation from GC CPU ratio
   - State management
   - Debug logging for decisions
   - Integration with existing ergonomics

Testing:
- Unit tests for control components
- Stress tests for thrashing detection
- Long-running application scenarios
- GC overhead validation

Files Changed:
- hotspot/share/gc/g1/g1HeapSizingPolicy.hpp
- hotspot/share/gc/g1/g1HeapSizingPolicy.cpp

Documentation:
- doc/G1-AHS-Implementation-Flow.md
- doc/G1-AHS-Container-Integration.md

Motivation:
The implementation provides dynamic heap sizing that:
1. Reduces manual tuning needs
2. Adapts to application behavior
3. Handles memory pressure gracefully
4. Improves container support