Skip to content

Commit fa32bfe

Browse files
rgithubliWilliam Kemper
authored andcommitted
8358529: GenShen: Heuristics do not respond to changes in SoftMaxHeapSize
Reviewed-by: wkemper
1 parent 91df797 commit fa32bfe

17 files changed

+145
-99
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ void ShenandoahAdaptiveHeuristics::choose_collection_set_from_regiondata(Shenand
9191
// we hit max_cset. When max_cset is hit, we terminate the cset selection. Note that in this scheme,
9292
// ShenandoahGarbageThreshold is the soft threshold which would be ignored until min_garbage is hit.
9393

94-
size_t capacity = _space_info->soft_max_capacity();
94+
size_t capacity = ShenandoahHeap::heap()->soft_max_capacity();
9595
size_t max_cset = (size_t)((1.0 * capacity / 100 * ShenandoahEvacReserve) / ShenandoahEvacWaste);
9696
size_t free_target = (capacity / 100 * ShenandoahMinFreeThreshold) + max_cset;
9797
size_t min_garbage = (free_target > actual_free ? (free_target - actual_free) : 0);
@@ -233,7 +233,7 @@ static double saturate(double value, double min, double max) {
233233
// in operation mode. We want some way to decide that the average rate has changed, while keeping average
234234
// allocation rate computation independent.
235235
bool ShenandoahAdaptiveHeuristics::should_start_gc() {
236-
size_t capacity = _space_info->soft_max_capacity();
236+
size_t capacity = ShenandoahHeap::heap()->soft_max_capacity();
237237
size_t available = _space_info->soft_available();
238238
size_t allocated = _space_info->bytes_allocated_since_gc_start();
239239

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ ShenandoahCompactHeuristics::ShenandoahCompactHeuristics(ShenandoahSpaceInfo* sp
4747

4848
bool ShenandoahCompactHeuristics::should_start_gc() {
4949
size_t max_capacity = _space_info->max_capacity();
50-
size_t capacity = _space_info->soft_max_capacity();
50+
size_t capacity = ShenandoahHeap::heap()->soft_max_capacity();
5151
size_t available = _space_info->available();
5252

5353
// Make sure the code below treats available without the soft tail.

src/hotspot/share/gc/shenandoah/heuristics/shenandoahSpaceInfo.hpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@
3737
class ShenandoahSpaceInfo {
3838
public:
3939
virtual const char* name() const = 0;
40-
virtual size_t soft_max_capacity() const = 0;
4140
virtual size_t max_capacity() const = 0;
4241
virtual size_t soft_available() const = 0;
4342
virtual size_t available() const = 0;

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ ShenandoahStaticHeuristics::~ShenandoahStaticHeuristics() {}
4242

4343
bool ShenandoahStaticHeuristics::should_start_gc() {
4444
size_t max_capacity = _space_info->max_capacity();
45-
size_t capacity = _space_info->soft_max_capacity();
45+
size_t capacity = ShenandoahHeap::heap()->soft_max_capacity();
4646
size_t available = _space_info->available();
4747

4848
// Make sure the code below treats available without the soft tail.

src/hotspot/share/gc/shenandoah/shenandoahGeneration.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ void ShenandoahGeneration::log_status(const char *msg) const {
183183
// byte size in proper unit and proper unit for byte size are consistent.
184184
const size_t v_used = used();
185185
const size_t v_used_regions = used_regions_size();
186-
const size_t v_soft_max_capacity = soft_max_capacity();
186+
const size_t v_soft_max_capacity = ShenandoahHeap::heap()->soft_max_capacity();
187187
const size_t v_max_capacity = max_capacity();
188188
const size_t v_available = available();
189189
const size_t v_humongous_waste = get_humongous_waste();
@@ -799,14 +799,13 @@ void ShenandoahGeneration::cancel_marking() {
799799

800800
ShenandoahGeneration::ShenandoahGeneration(ShenandoahGenerationType type,
801801
uint max_workers,
802-
size_t max_capacity,
803-
size_t soft_max_capacity) :
802+
size_t max_capacity) :
804803
_type(type),
805804
_task_queues(new ShenandoahObjToScanQueueSet(max_workers)),
806805
_ref_processor(new ShenandoahReferenceProcessor(MAX2(max_workers, 1U))),
807806
_affiliated_region_count(0), _humongous_waste(0), _evacuation_reserve(0),
808807
_used(0), _bytes_allocated_since_gc_start(0),
809-
_max_capacity(max_capacity), _soft_max_capacity(soft_max_capacity),
808+
_max_capacity(max_capacity),
810809
_heuristics(nullptr)
811810
{
812811
_is_marking_complete.set();
@@ -952,7 +951,7 @@ size_t ShenandoahGeneration::available_with_reserve() const {
952951
}
953952

954953
size_t ShenandoahGeneration::soft_available() const {
955-
return available(soft_max_capacity());
954+
return available(ShenandoahHeap::heap()->soft_max_capacity());
956955
}
957956

958957
size_t ShenandoahGeneration::available(size_t capacity) const {

src/hotspot/share/gc/shenandoah/shenandoahGeneration.hpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,6 @@ class ShenandoahGeneration : public CHeapObj<mtGC>, public ShenandoahSpaceInfo {
7171
volatile size_t _used;
7272
volatile size_t _bytes_allocated_since_gc_start;
7373
size_t _max_capacity;
74-
size_t _soft_max_capacity;
7574

7675
ShenandoahHeuristics* _heuristics;
7776

@@ -105,8 +104,7 @@ class ShenandoahGeneration : public CHeapObj<mtGC>, public ShenandoahSpaceInfo {
105104
public:
106105
ShenandoahGeneration(ShenandoahGenerationType type,
107106
uint max_workers,
108-
size_t max_capacity,
109-
size_t soft_max_capacity);
107+
size_t max_capacity);
110108
~ShenandoahGeneration();
111109

112110
bool is_young() const { return _type == YOUNG; }
@@ -126,7 +124,6 @@ class ShenandoahGeneration : public CHeapObj<mtGC>, public ShenandoahSpaceInfo {
126124

127125
virtual ShenandoahHeuristics* initialize_heuristics(ShenandoahMode* gc_mode);
128126

129-
size_t soft_max_capacity() const override { return _soft_max_capacity; }
130127
size_t max_capacity() const override { return _max_capacity; }
131128
virtual size_t used_regions() const;
132129
virtual size_t used_regions_size() const;

src/hotspot/share/gc/shenandoah/shenandoahGenerationalHeap.cpp

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -53,21 +53,6 @@ class ShenandoahGenerationalInitLogger : public ShenandoahInitLogger {
5353
ShenandoahGenerationalInitLogger logger;
5454
logger.print_all();
5555
}
56-
57-
void print_heap() override {
58-
ShenandoahInitLogger::print_heap();
59-
60-
ShenandoahGenerationalHeap* heap = ShenandoahGenerationalHeap::heap();
61-
62-
ShenandoahYoungGeneration* young = heap->young_generation();
63-
log_info(gc, init)("Young Generation Soft Size: " EXACTFMT, EXACTFMTARGS(young->soft_max_capacity()));
64-
log_info(gc, init)("Young Generation Max: " EXACTFMT, EXACTFMTARGS(young->max_capacity()));
65-
66-
ShenandoahOldGeneration* old = heap->old_generation();
67-
log_info(gc, init)("Old Generation Soft Size: " EXACTFMT, EXACTFMTARGS(old->soft_max_capacity()));
68-
log_info(gc, init)("Old Generation Max: " EXACTFMT, EXACTFMTARGS(old->max_capacity()));
69-
}
70-
7156
protected:
7257
void print_gc_specific() override {
7358
ShenandoahInitLogger::print_gc_specific();
@@ -141,8 +126,8 @@ void ShenandoahGenerationalHeap::initialize_heuristics() {
141126
size_t initial_capacity_old = max_capacity() - max_capacity_young;
142127
size_t max_capacity_old = max_capacity() - initial_capacity_young;
143128

144-
_young_generation = new ShenandoahYoungGeneration(max_workers(), max_capacity_young, initial_capacity_young);
145-
_old_generation = new ShenandoahOldGeneration(max_workers(), max_capacity_old, initial_capacity_old);
129+
_young_generation = new ShenandoahYoungGeneration(max_workers(), max_capacity_young);
130+
_old_generation = new ShenandoahOldGeneration(max_workers(), max_capacity_old);
146131
_young_generation->initialize_heuristics(mode());
147132
_old_generation->initialize_heuristics(mode());
148133
}

src/hotspot/share/gc/shenandoah/shenandoahGlobalGeneration.cpp

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,6 @@ size_t ShenandoahGlobalGeneration::used_regions_size() const {
5050
return ShenandoahHeap::heap()->capacity();
5151
}
5252

53-
size_t ShenandoahGlobalGeneration::soft_max_capacity() const {
54-
return ShenandoahHeap::heap()->soft_max_capacity();
55-
}
56-
5753
size_t ShenandoahGlobalGeneration::available() const {
5854
// The collector reserve may eat into what the mutator is allowed to use. Make sure we are looking
5955
// at what is available to the mutator when reporting how much memory is available.
@@ -65,8 +61,8 @@ size_t ShenandoahGlobalGeneration::soft_available() const {
6561
size_t available = this->available();
6662

6763
// Make sure the code below treats available without the soft tail.
68-
assert(max_capacity() >= soft_max_capacity(), "Max capacity must be greater than soft max capacity.");
69-
size_t soft_tail = max_capacity() - soft_max_capacity();
64+
assert(max_capacity() >= ShenandoahHeap::heap()->soft_max_capacity(), "Max capacity must be greater than soft max capacity.");
65+
size_t soft_tail = max_capacity() - ShenandoahHeap::heap()->soft_max_capacity();
7066
return (available > soft_tail) ? (available - soft_tail) : 0;
7167
}
7268

src/hotspot/share/gc/shenandoah/shenandoahGlobalGeneration.hpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,13 @@
3232
// A "generation" that represents the whole heap.
3333
class ShenandoahGlobalGeneration : public ShenandoahGeneration {
3434
public:
35-
ShenandoahGlobalGeneration(bool generational, uint max_queues, size_t max_capacity, size_t soft_max_capacity)
36-
: ShenandoahGeneration(generational ? GLOBAL : NON_GEN, max_queues, max_capacity, soft_max_capacity) { }
35+
ShenandoahGlobalGeneration(bool generational, uint max_queues, size_t max_capacity)
36+
: ShenandoahGeneration(generational ? GLOBAL : NON_GEN, max_queues, max_capacity) { }
3737

3838
public:
3939
const char* name() const override;
4040

4141
size_t max_capacity() const override;
42-
size_t soft_max_capacity() const override;
4342
size_t used_regions() const override;
4443
size_t used_regions_size() const override;
4544
size_t available() const override;

src/hotspot/share/gc/shenandoah/shenandoahHeap.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
#include "gc/shared/gcArguments.hpp"
3333
#include "gc/shared/gcTimer.hpp"
3434
#include "gc/shared/gcTraceTime.inline.hpp"
35+
#include "gc/shared/gc_globals.hpp"
3536
#include "gc/shared/locationPrinter.inline.hpp"
3637
#include "gc/shared/memAllocator.hpp"
3738
#include "gc/shared/plab.hpp"
@@ -201,8 +202,7 @@ jint ShenandoahHeap::initialize() {
201202
assert(num_min_regions <= _num_regions, "sanity");
202203
_minimum_size = num_min_regions * reg_size_bytes;
203204

204-
// Default to max heap size.
205-
_soft_max_size = _num_regions * reg_size_bytes;
205+
_soft_max_size = SoftMaxHeapSize;
206206

207207
_committed = _initial_size;
208208

@@ -524,7 +524,7 @@ void ShenandoahHeap::initialize_mode() {
524524
}
525525

526526
void ShenandoahHeap::initialize_heuristics() {
527-
_global_generation = new ShenandoahGlobalGeneration(mode()->is_generational(), max_workers(), max_capacity(), max_capacity());
527+
_global_generation = new ShenandoahGlobalGeneration(mode()->is_generational(), max_workers(), max_capacity());
528528
_global_generation->initialize_heuristics(mode());
529529
}
530530

0 commit comments

Comments
 (0)