RFR: 8357445: G1: Time-Based Heap Uncommit During Idle Periods [v8]

Monica Beckwith mbeckwit at openjdk.org
Thu Oct 16 20:35:01 UTC 2025


> **Implements:** https://bugs.openjdk.org/browse/JDK-8357445
> 
> Implement time-based heap uncommit for G1 during idle periods.
> 
> Key changes:
> - Added G1HeapEvaluationTask for periodic heap evaluation
> - Switch from G1ServiceTask to PeriodicTask for improved scheduling
> - Implemented time-based heap sizing policy with configurable uncommit delay
> - Added region activity tracking with last access timestamps
> - Integrated VM_G1ShrinkHeap operation for safe heap shrinking
> - Added new G1 flags: G1UseTimeBasedHeapSizing, G1TimeBasedEvaluationIntervalMillis, G1UncommitDelayMillis, G1MinRegionsToUncommit
> - Added 'sizing' log tag for heap sizing operations
> 
> Comprehensive Test Coverage:
> - Enhanced TestG1RegionUncommit: minimum heap boundaries, concurrent allocation/uncommit scenarios
> - Enhanced TestTimeBasedHeapSizing: humongous object handling, rapid allocation cycles, edge cases
> - Enhanced TestTimeBasedRegionTracking: concurrent region access, lifecycle transition validation
> - Enhanced TestTimeBasedHeapConfig: parameter boundary values, small heap configurations
> 
> This ensures time-based heap uncommit works correctly while maintaining all safety guarantees and test expectations.

Monica Beckwith has updated the pull request with a new target base due to a merge or a rebase. The pull request now contains 10 commits:

 - Merge master
 - Address OpenJDK PR feedback on time-based heap uncommit and region selection
 - Remove unused static _uncommit_delay member and accessor
 - Resolve merge conflict - keep proper @tschatzl time type implementation
   
   - Keep Tickspan::from_milliseconds(G1UncommitDelayMillis) initialization
   - Keep (jlong)elapsed.milliseconds() cast for macOS build compatibility
   - Keep elapsed > _uncommit_delay direct Tickspan comparison
   - Maintains cross-platform compatibility
 - JDK-8357445: Implement @tschatzl code review feedback for time-based heap sizing
   
   - Convert from jlong milliseconds to proper time types (Ticks/Tickspan)
   - Reclassify G1UseTimeBasedHeapSizing from EXPERIMENTAL+false to DIAGNOSTIC+true
   - Reclassify G1MinRegionsToUncommit from EXPERIMENTAL to DIAGNOSTIC
   - Keep timing flags (G1UncommitDelayMillis, G1HeapEvaluationIntervalMillis) as MANAGEABLE
   - Update all test files to use UnlockDiagnosticVMOptions instead of UnlockExperimentalVMOptions
   - Remove explicit G1UseTimeBasedHeapSizing=true from tests (now enabled by default)
   - Improve logging terminology from 'time-based' to 'uncommit evaluation'
   - Fix comment style and remove unused heap_sizing_policy() accessor
   - Comprehensive type safety improvements throughout the codebase
   
   This addresses all feedback regarding type safety, flag design,
   and production readiness of the time-based heap sizing feature.
 - JDK-8357445: Implement @tschatzl code review feedback for time-based heap sizing
   
   - Convert from jlong milliseconds to proper time types (Ticks/Tickspan)
   - Reclassify G1UseTimeBasedHeapSizing from EXPERIMENTAL+false to DIAGNOSTIC+true
   - Reclassify G1MinRegionsToUncommit from EXPERIMENTAL to DIAGNOSTIC
   - Keep timing flags (G1UncommitDelayMillis, G1HeapEvaluationIntervalMillis) as MANAGEABLE
   - Update all test files to use UnlockDiagnosticVMOptions instead of UnlockExperimentalVMOptions
   - Remove explicit G1UseTimeBasedHeapSizing=true from tests (now enabled by default)
   - Improve logging terminology from 'time-based' to 'uncommit evaluation'
   - Fix comment style and remove unused heap_sizing_policy() accessor
   - Comprehensive type safety improvements throughout the codebase
   
   This addresses all feedback regarding type safety, flag design,
   and production readiness of the time-based heap sizing feature.
 - 8357445: Remove redundant record_activity calls and leftover initialize call
   
   - Remove record_activity() from retirement methods as hr_clear() is always last
   - Remove leftover initialize() call since initialization moved to constructor
   - Remove unused G1 includes from vmOperations after moving VM_G1ShrinkHeap
 - 8357445: Address code review feedback
   
   Extra line removed
   Include cycle comment removed
   completed changed to flagged
   nullptr assignment changed to assert
   Redundant nullptr check removed
   VM_G1ShrinkHeap moved
   Forward declaration removed
   Constructor initialization for static _uncommit_delay_ms
 - Normalize encoding and line endings for G1 GC time-based tests
 - JDK-8357445: G1: Time-Based Heap Uncommit During Idle Periods
   
   Implement time-based heap uncommit for G1 during idle periods.
   
   Key changes:
   - Added G1HeapEvaluationTask for periodic heap evaluation
   - Switch from G1ServiceTask to PeriodicTask for virtual thread support
   - Implemented time-based heap sizing policy with configurable uncommit delay
   - Added region activity tracking with last access timestamps
   - Integrated VM_G1ShrinkHeap operation for safe heap shrinking
   - Added new G1 flags: G1UseTimeBasedHeapSizing, G1TimeBasedEvaluationIntervalMillis, G1UncommitDelayMillis, G1MinRegionsToUncommit
   - Added 'sizing' log tag for heap sizing operations
   
   Comprehensive Test Coverage:
   - Enhanced TestG1RegionUncommit: minimum heap boundaries, concurrent allocation/uncommit scenarios
   - Enhanced TestTimeBasedHeapSizing: humongous object handling, rapid allocation cycles, edge cases
   - Enhanced TestTimeBasedRegionTracking: concurrent region access, lifecycle transition validation
   - Enhanced TestTimeBasedHeapConfig: parameter boundary values, small heap configurations
   
   This ensures time-based heap uncommit works correctly while maintaining all safety guarantees and test expectations.

-------------

Changes: https://git.openjdk.org/jdk/pull/26240/files
  Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=26240&range=07
  Stats: 1779 lines in 22 files changed: 1759 ins; 2 del; 18 mod
  Patch: https://git.openjdk.org/jdk/pull/26240.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/26240/head:pull/26240

PR: https://git.openjdk.org/jdk/pull/26240


More information about the hotspot-dev mailing list