/* * Copyright (c) 2004, 2022, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. *
*/
// Goal for the fraction of the total time during which application // threads run constdouble _throughput_goal;
// Last calculated sizes, in bytes, and aligned
size_t _eden_size; // calculated eden free space in bytes
size_t _promo_size; // calculated promoted free space in bytes
size_t _survivor_size; // calculated survivor size in bytes
// Support for UseGCOverheadLimit
GCOverheadChecker _overhead_checker;
// Minor collection timers used to determine both // pause and interval times for collections static elapsedTimer _minor_timer;
// Major collection timers, used to determine both // pause and interval times for collections static elapsedTimer _major_timer;
// Time statistics
AdaptivePaddedAverage* _avg_minor_pause;
AdaptiveWeightedAverage* _avg_minor_interval;
AdaptiveWeightedAverage* _avg_minor_gc_cost;
// Statistics for survivor space calculation for young generation
AdaptivePaddedAverage* _avg_survived;
// Objects that have been directly allocated in the old generation
AdaptivePaddedNoZeroDevAverage* _avg_pretenured;
// Variable for estimating the major and minor pause times. // These variables represent linear least-squares fits of // the data. // minor pause time vs. old gen size
LinearLeastSquareFit* _minor_pause_old_estimator; // minor pause time vs. young gen size
LinearLeastSquareFit* _minor_pause_young_estimator;
// Variables for estimating the major and minor collection costs // minor collection time vs. young gen size
LinearLeastSquareFit* _minor_collection_estimator; // major collection time vs. old gen size
LinearLeastSquareFit* _major_collection_estimator;
// These record the most recent collection times. They // are available as an alternative to using the averages // for making ergonomic decisions. double _latest_minor_mutator_interval_seconds;
// Allowed difference between major and minor GC times, used // for computing tenuring_threshold constdouble _threshold_tolerance_percent;
constdouble _gc_pause_goal_sec; // Goal for maximum GC pause
// Flag indicating that the adaptive policy is ready to use bool _young_gen_policy_is_ready;
// Decrease/increase the young generation for minor pause time int _change_young_gen_for_min_pauses;
// Decrease/increase the old generation for major pause time int _change_old_gen_for_maj_pauses;
// change old generation for throughput int _change_old_gen_for_throughput;
// change young generation for throughput int _change_young_gen_for_throughput;
// Flag indicating that the policy would // increase the tenuring threshold because of the total major GC cost // is greater than the total minor GC cost bool _increment_tenuring_threshold_for_gc_cost; // decrease the tenuring threshold because of the total minor GC // cost is greater than the total major GC cost bool _decrement_tenuring_threshold_for_gc_cost; // decrease due to survivor size limit bool _decrement_tenuring_threshold_for_survivor_limit;
// decrease generation sizes for footprint int _decrease_for_footprint;
// Set if the ergonomic decisions were made at a full GC. int _decide_at_full_gc;
// Changing the generation sizing depends on the data that is // gathered about the effects of changes on the pause times and // throughput. These variable count the number of data points // gathered. The policy may use these counters as a threshold // for reliable data.
julong _young_gen_change_for_minor_throughput;
julong _old_gen_change_for_major_throughput;
// Accessors
double gc_pause_goal_sec() const { return _gc_pause_goal_sec; } // The value returned is unitless: it's the proportion of time // spent in a particular collection type. // An interval time will be 0.0 if a collection type hasn't occurred yet. // The 1.4.2 implementation put a floor on the values of major_gc_cost // and minor_gc_cost. This was useful because of the way major_gc_cost // and minor_gc_cost was used in calculating the sizes of the generations. // Do not use a floor in this implementation because any finite value // will put a limit on the throughput that can be achieved and any // throughput goal above that limit will drive the generations sizes // to extremes. double major_gc_cost() const { return MAX2(0.0F, _avg_major_gc_cost->average());
}
// The value returned is unitless: it's the proportion of time // spent in a particular collection type. // An interval time will be 0.0 if a collection type hasn't occurred yet. // The 1.4.2 implementation put a floor on the values of major_gc_cost // and minor_gc_cost. This was useful because of the way major_gc_cost // and minor_gc_cost was used in calculating the sizes of the generations. // Do not use a floor in this implementation because any finite value // will put a limit on the throughput that can be achieved and any // throughput goal above that limit will drive the generations sizes // to extremes.
// Because we're dealing with averages, gc_cost() can be // larger than 1.0 if just the sum of the minor cost the // the major cost is used. Worse than that is the // fact that the minor cost and the major cost each // tend toward 1.0 in the extreme of high GC costs. // Limit the value of gc_cost to 1.0 so that the mutator // cost stays non-negative. virtualdouble gc_cost() const { double result = MIN2(1.0, minor_gc_cost() + major_gc_cost());
assert(result >= 0.0, "Both minor and major costs are non-negative"); return result;
}
// Elapsed time since the last major collection. virtualdouble time_since_major_gc() const;
// Average interval between major collections to be used // in calculating the decaying major GC cost. An overestimate // of this time would be a conservative estimate because // this time is used to decide if the major GC cost // should be decayed (i.e., if the time since the last // major GC is long compared to the time returned here, // then the major GC cost will be decayed). See the // implementations for the specifics. virtualdouble major_gc_interval_average_for_decay() const { return _avg_major_interval->average();
}
// Return the cost of the GC where the major GC cost // has been decayed based on the time since the last // major collection. double decaying_gc_cost() const;
// Decay the major GC cost. Use this only for decisions on // whether to adjust, not to determine by how much to adjust. // This approximation is crude and may not be good enough for the // latter. double decaying_major_gc_cost() const;
// Return the mutator cost using the decayed // GC cost. double adjusted_mutator_cost() const { double result = 1.0 - decaying_gc_cost();
assert(result >= 0.0, "adjusted mutator cost calculation is incorrect"); return result;
}
void update_minor_pause_young_estimator(double minor_pause_in_ms); virtualvoid update_minor_pause_old_estimator(double minor_pause_in_ms) { // This is not meaningful for all policies but needs to be present // to use minor_collection_end() in its current form.
}
// Methods indicating events of interest to the adaptive size policy, // called by GC algorithms. It is the responsibility of users of this // policy to call these methods at the correct times! virtualvoid minor_collection_begin(); virtualvoid minor_collection_end(GCCause::Cause gc_cause); virtual LinearLeastSquareFit* minor_pause_old_estimator() const { return _minor_pause_old_estimator;
}
void reset_gc_overhead_limit_count() {
_overhead_checker.reset_gc_overhead_limit_count();
} // accessors for flags recording the decisions to resize the // generations to meet the pause goal.
// Check the conditions for an out-of-memory due to excessive GC time. // Set _gc_overhead_limit_exceeded if all the conditions have been met. void check_gc_overhead_limit(size_t eden_live,
size_t max_old_gen_size,
size_t max_eden_size, bool is_full_gc,
GCCause::Cause gc_cause,
SoftRefPolicy* soft_ref_policy);
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.