Skip to content

Commit 4de4c3e

Browse files
caojoshuaWilliam Kemper
authored and
William Kemper
committedJul 6, 2022
cli options for young/old ShenandoahMinFreeThreshold
Reviewed-by: wkemper, ysr
1 parent 3c066d4 commit 4de4c3e

6 files changed

+25
-7
lines changed
 

‎src/hotspot/share/gc/shenandoah/heuristics/shenandoahAdaptiveHeuristics.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ bool ShenandoahAdaptiveHeuristics::should_start_gc() {
273273
double rate = _allocation_rate.sample(allocated);
274274
_last_trigger = OTHER;
275275

276-
size_t min_threshold = capacity / 100 * ShenandoahMinFreeThreshold;
276+
size_t min_threshold = min_free_threshold();
277277

278278
if (allocation_headroom < min_threshold) {
279279
log_info(gc)("Trigger (%s): Free (" SIZE_FORMAT "%s) is below minimum threshold (" SIZE_FORMAT "%s)",

‎src/hotspot/share/gc/shenandoah/heuristics/shenandoahCompactHeuristics.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ bool ShenandoahCompactHeuristics::should_start_gc() {
5555
available = (available > soft_tail) ? (available - soft_tail) : 0;
5656

5757
size_t threshold_bytes_allocated = capacity / 100 * ShenandoahAllocationThreshold;
58-
size_t min_threshold = capacity / 100 * ShenandoahMinFreeThreshold;
58+
size_t min_threshold = min_free_threshold();
5959

6060
if (available < min_threshold) {
6161
log_info(gc)("Trigger: Free (" SIZE_FORMAT "%s) is below minimum threshold (" SIZE_FORMAT "%s)",

‎src/hotspot/share/gc/shenandoah/heuristics/shenandoahHeuristics.cpp

+8
Original file line numberDiff line numberDiff line change
@@ -512,6 +512,14 @@ bool ShenandoahHeuristics::in_generation(ShenandoahHeapRegion* region) {
512512
|| (_generation->generation_mode() == OLD && region->affiliation() == OLD_GENERATION));
513513
}
514514

515+
size_t ShenandoahHeuristics::min_free_threshold() {
516+
size_t min_free_threshold =
517+
_generation->generation_mode() == GenerationMode::OLD
518+
? ShenandoahOldMinFreeThreshold
519+
: ShenandoahMinFreeThreshold;
520+
return _generation->soft_max_capacity() / 100 * min_free_threshold;
521+
}
522+
515523
void ShenandoahHeuristics::save_last_live_memory(size_t live_memory) {
516524
_live_memory_penultimate_cycle = _live_memory_last_cycle;
517525
_live_memory_last_cycle = live_memory;

‎src/hotspot/share/gc/shenandoah/heuristics/shenandoahHeuristics.hpp

+2
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,8 @@ class ShenandoahHeuristics : public CHeapObj<mtGC> {
119119

120120
bool in_generation(ShenandoahHeapRegion* region);
121121

122+
size_t min_free_threshold();
123+
122124
public:
123125
ShenandoahHeuristics(ShenandoahGeneration* generation);
124126
virtual ~ShenandoahHeuristics();

‎src/hotspot/share/gc/shenandoah/heuristics/shenandoahStaticHeuristics.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ bool ShenandoahStaticHeuristics::should_start_gc() {
4949
size_t soft_tail = max_capacity - capacity;
5050
available = (available > soft_tail) ? (available - soft_tail) : 0;
5151

52-
size_t threshold_available = capacity / 100 * ShenandoahMinFreeThreshold;
52+
size_t threshold_available = min_free_threshold();
5353

5454
if (available < threshold_available) {
5555
log_info(gc)("Trigger: Free (" SIZE_FORMAT "%s) is below minimum threshold (" SIZE_FORMAT "%s)",

‎src/hotspot/share/gc/shenandoah/shenandoah_globals.hpp

+12-4
Original file line numberDiff line numberDiff line change
@@ -111,10 +111,18 @@
111111
range(0,100) \
112112
\
113113
product(uintx, ShenandoahMinFreeThreshold, 10, EXPERIMENTAL, \
114-
"Percentage of free heap memory below which most heuristics " \
115-
"trigger collection independent of other triggers. Provides " \
116-
"a safety margin for many heuristics. In percents of (soft) " \
117-
"max heap size.") \
114+
"Percentage of free heap memory (or young generation, in " \
115+
"generational mode) below which most heuristics trigger " \
116+
"collection independent of other triggers. Provides a safety " \
117+
"margin for many heuristics. In percents of (soft) max heap " \
118+
"size.") \
119+
range(0,100) \
120+
\
121+
product(uintx, ShenandoahOldMinFreeThreshold, 5, EXPERIMENTAL, \
122+
"Percentage of free old generation heap memory below which most " \
123+
"heuristics trigger collection independent of other triggers. " \
124+
"Provides a safety margin for many heuristics. In percents of " \
125+
"(soft) max heap size.") \
118126
range(0,100) \
119127
\
120128
product(uintx, ShenandoahAllocationThreshold, 0, EXPERIMENTAL, \

0 commit comments

Comments
 (0)
Please sign in to comment.