8294845: Make globals accessed by G1 young gen revising atomic
Reviewed-by: iwalulya, kbarrett
This commit is contained in:
parent
dac6ecc857
commit
6626a29a74
@ -194,19 +194,30 @@ void G1Policy::update_young_length_bounds() {
|
||||
}
|
||||
|
||||
void G1Policy::update_young_length_bounds(size_t pending_cards, size_t rs_length) {
|
||||
uint old_young_list_target_length = _young_list_target_length;
|
||||
uint old_young_list_target_length = young_list_target_length();
|
||||
|
||||
_young_list_desired_length = calculate_young_desired_length(pending_cards, rs_length);
|
||||
_young_list_target_length = calculate_young_target_length(_young_list_desired_length);
|
||||
_young_list_max_length = calculate_young_max_length(_young_list_target_length);
|
||||
uint new_young_list_desired_length = calculate_young_desired_length(pending_cards, rs_length);
|
||||
uint new_young_list_target_length = calculate_young_target_length(new_young_list_desired_length);
|
||||
uint new_young_list_max_length = calculate_young_max_length(new_young_list_target_length);
|
||||
|
||||
log_trace(gc, ergo, heap)("Young list length update: pending cards %zu rs_length %zu old target %u desired: %u target: %u max: %u",
|
||||
pending_cards,
|
||||
rs_length,
|
||||
old_young_list_target_length,
|
||||
_young_list_desired_length,
|
||||
_young_list_target_length,
|
||||
_young_list_max_length);
|
||||
new_young_list_desired_length,
|
||||
new_young_list_target_length,
|
||||
new_young_list_max_length);
|
||||
|
||||
// Write back. This is not an attempt to control visibility order to other threads
|
||||
// here; all the revising of the young gen length are best effort to keep pause time.
|
||||
// E.g. we could be "too late" revising young gen upwards to avoid GC because
|
||||
// there is some time left, or some threads could get different values for stopping
|
||||
// allocation.
|
||||
// That is "fine" - at most this will schedule a GC (hopefully only a little) too
|
||||
// early or too late.
|
||||
Atomic::store(&_young_list_desired_length, new_young_list_desired_length);
|
||||
Atomic::store(&_young_list_target_length, new_young_list_target_length);
|
||||
Atomic::store(&_young_list_max_length, new_young_list_max_length);
|
||||
}
|
||||
|
||||
// Calculates desired young gen length. It is calculated from:
|
||||
@ -1088,14 +1099,12 @@ double G1Policy::predict_region_total_time_ms(HeapRegion* hr, bool for_young_onl
|
||||
|
||||
bool G1Policy::should_allocate_mutator_region() const {
|
||||
uint young_list_length = _g1h->young_regions_count();
|
||||
uint young_list_target_length = _young_list_target_length;
|
||||
return young_list_length < young_list_target_length;
|
||||
return young_list_length < young_list_target_length();
|
||||
}
|
||||
|
||||
bool G1Policy::can_expand_young_list() const {
|
||||
uint young_list_length = _g1h->young_regions_count();
|
||||
uint young_list_max_length = _young_list_max_length;
|
||||
return young_list_length < young_list_max_length;
|
||||
return young_list_length < young_list_max_length();
|
||||
}
|
||||
|
||||
bool G1Policy::use_adaptive_young_list_length() const {
|
||||
@ -1124,8 +1133,8 @@ void G1Policy::print_age_table() {
|
||||
uint G1Policy::calculate_young_max_length(uint target_young_length) const {
|
||||
uint expansion_region_num = 0;
|
||||
if (GCLockerEdenExpansionPercent > 0) {
|
||||
double perc = (double) GCLockerEdenExpansionPercent / 100.0;
|
||||
double expansion_region_num_d = perc * (double) _young_list_target_length;
|
||||
double perc = GCLockerEdenExpansionPercent / 100.0;
|
||||
double expansion_region_num_d = perc * young_list_target_length();
|
||||
// We use ceiling so that if expansion_region_num_d is > 0.0 (but
|
||||
// less than 1.0) we'll get 1.
|
||||
expansion_region_num = (uint) ceil(expansion_region_num_d);
|
||||
@ -1138,7 +1147,7 @@ uint G1Policy::calculate_young_max_length(uint target_young_length) const {
|
||||
// Calculates survivor space parameters.
|
||||
void G1Policy::update_survivors_policy() {
|
||||
double max_survivor_regions_d =
|
||||
(double) _young_list_target_length / (double) SurvivorRatio;
|
||||
(double)young_list_target_length() / (double) SurvivorRatio;
|
||||
|
||||
// Calculate desired survivor size based on desired max survivor regions (unconstrained
|
||||
// by remaining heap). Otherwise we may cause undesired promotions as we are
|
||||
|
@ -35,6 +35,7 @@
|
||||
#include "gc/g1/g1Predictions.hpp"
|
||||
#include "gc/g1/g1YoungGenSizer.hpp"
|
||||
#include "gc/shared/gcCause.hpp"
|
||||
#include "runtime/atomic.hpp"
|
||||
#include "utilities/pair.hpp"
|
||||
#include "utilities/ticks.hpp"
|
||||
|
||||
@ -77,12 +78,14 @@ class G1Policy: public CHeapObj<mtGC> {
|
||||
|
||||
double _full_collection_start_sec;
|
||||
|
||||
uint _young_list_desired_length;
|
||||
uint _young_list_target_length;
|
||||
|
||||
// Desired young gen length without taking actually available free regions into
|
||||
// account.
|
||||
volatile uint _young_list_desired_length;
|
||||
// Actual target length given available free memory.
|
||||
volatile uint _young_list_target_length;
|
||||
// The max number of regions we can extend the eden by while the GC
|
||||
// locker is active. This should be >= _young_list_target_length;
|
||||
uint _young_list_max_length;
|
||||
volatile uint _young_list_max_length;
|
||||
|
||||
// The survivor rate groups below must be initialized after the predictor because they
|
||||
// indirectly use it through the "this" object passed to their constructor.
|
||||
@ -379,17 +382,14 @@ public:
|
||||
// This must be called at the very beginning of an evacuation pause.
|
||||
void decide_on_concurrent_start_pause();
|
||||
|
||||
uint young_list_desired_length() const { return _young_list_desired_length; }
|
||||
uint young_list_target_length() const { return _young_list_target_length; }
|
||||
uint young_list_desired_length() const { return Atomic::load(&_young_list_desired_length); }
|
||||
uint young_list_target_length() const { return Atomic::load(&_young_list_target_length); }
|
||||
uint young_list_max_length() const { return Atomic::load(&_young_list_max_length); }
|
||||
|
||||
bool should_allocate_mutator_region() const;
|
||||
|
||||
bool can_expand_young_list() const;
|
||||
|
||||
uint young_list_max_length() const {
|
||||
return _young_list_max_length;
|
||||
}
|
||||
|
||||
bool use_adaptive_young_list_length() const;
|
||||
|
||||
// Return an estimate of the number of bytes used in young gen.
|
||||
|
Loading…
Reference in New Issue
Block a user