RFR: 8357445: G1: Time-Based Heap Uncommit During Idle Periods [v13]
Monica Beckwith
mbeckwit at openjdk.org
Fri Feb 6 01:55:02 UTC 2026
> **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 16 commits:
- 8357445: Address review feedback with O(1) timestamp reset
- Implement O(1) global timestamp reset
- Add _last_gc_timestamp member for baseline tracking
- Call reset_free_region_timestamps() after young and full GC
- Use MAX2(region_time, _last_gc_time) for effective timestamp calculation
- Change request_heap_shrink() return type to void
- Remove unused deactivate_region_at() method
- Simplify comments to follow conventions
- Remove redundant ResourceMark and duplicate logging
- Merge master into feature branch
- Address Thomas Schatzl's review comments for JDK-8357445
This commit addresses all issues raised in Thomas's November 2025 review
of the time-based heap uncommit feature (PR #26240).
Major architectural fix:
- VM_G1ShrinkHeap::doit() now re-evaluates uncommit candidates at safepoint
time by calling find_uncommit_candidates_by_time() during VM operation
execution. This ensures regions are validated as still free at the point
of uncommit, fixing the race condition where heap state could change
between service thread evaluation and VM operation execution.
Code quality improvements:
- Removed redundant is_empty() checks in g1HeapSizingPolicy.cpp and
g1HeapRegionManager.cpp since is_free() already implies empty
- Replaced inefficient bubble sort with GrowableArray::sort() using
lambda comparator for O(n log n) performance
- Fixed lambda signature (G1HeapRegion** instead of const*) to match
GrowableArray::sort() requirements
- Added periods to sentence-style comments for consistency
The implementation already had correct:
- SuspendibleThreadSetJoiner placement in service thread task
- GC coordination with 5% overhead threshold and G1ReservePercent
- Proper assertions and validations
Tested with SPECjbb2015 showing correct time-based region selection
and uncommit behavior across varying load patterns.
- Fix compilation errors after master merge
- Fix syntax error in g1CollectedHeap.cpp (extra closing brace)
- Update API call from short_term_pause_time_ratio() to short_term_gc_time_ratio()
These fixes resolve compilation issues that occurred after merging with
upstream master due to API changes in the OpenJDK codebase.
- 8357445: Address feedback for G1 time-based heap sizing
- Fix indentation in log_debug statement in shrink_helper (suggested by @tschatzl)
- Change terminology from 'inactive' to 'idle' throughout time-based heap sizing
- Update flag descriptions in g1_globals.hpp to use 'idle' terminology
- Fix remaining trailing whitespace in test files
Addresses all outstanding review comments from @tschatzl
- 8357445: Fix trailing whitespace issues in G1 time-based heap sizing implementation
- Remove trailing whitespace from all modified G1 files
- Resolves OpenJDK jcheck whitespace validation errors
- No functional changes, whitespace cleanup only
- 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
- ... and 6 more: https://git.openjdk.org/jdk/compare/f5fa9e40...2c216279
-------------
Changes: https://git.openjdk.org/jdk/pull/26240/files
Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=26240&range=12
Stats: 1774 lines in 22 files changed: 1758 ins; 7 del; 9 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