8327365: Inline and remove GCStats

Reviewed-by: gli, tschatzl
This commit is contained in:
Albert Mingkun Yang 2024-03-06 13:04:38 +00:00
parent 326c91e1a2
commit ae5e3fdd59
7 changed files with 14 additions and 97 deletions

View File

@ -49,7 +49,7 @@ PSAdaptiveSizePolicy::PSAdaptiveSizePolicy(size_t init_eden_size,
gc_cost_ratio),
_avg_major_pause(new AdaptivePaddedAverage(AdaptiveTimeWeight, PausePadding)),
_avg_base_footprint(new AdaptiveWeightedAverage(AdaptiveSizePolicyWeight)),
_gc_stats(),
_avg_promoted(new AdaptivePaddedNoZeroDevAverage(AdaptiveSizePolicyWeight, PromotedPadding)),
_major_pause_old_estimator(new LinearLeastSquareFit(AdaptiveSizePolicyWeight)),
_major_pause_young_estimator(new LinearLeastSquareFit(AdaptiveSizePolicyWeight)),
_latest_major_mutator_interval_seconds(0),

View File

@ -27,7 +27,6 @@
#include "gc/shared/adaptiveSizePolicy.hpp"
#include "gc/shared/gcCause.hpp"
#include "gc/shared/gcStats.hpp"
#include "gc/shared/gcUtil.hpp"
#include "utilities/align.hpp"
@ -72,8 +71,8 @@ class PSAdaptiveSizePolicy : public AdaptiveSizePolicy {
// Footprint statistics
AdaptiveWeightedAverage* _avg_base_footprint;
// Statistical data gathered for GC
GCStats _gc_stats;
// Statistics for promoted objs
AdaptivePaddedNoZeroDevAverage* _avg_promoted;
// Variable for estimating the major and minor pause times.
// These variables represent linear least-squares fits of
@ -166,7 +165,7 @@ class PSAdaptiveSizePolicy : public AdaptiveSizePolicy {
public:
// Accessors for use by performance counters
AdaptivePaddedNoZeroDevAverage* avg_promoted() const {
return _gc_stats.avg_promoted();
return _avg_promoted;
}
AdaptiveWeightedAverage* avg_base_footprint() const {
return _avg_base_footprint;

View File

@ -51,9 +51,7 @@
class DefNewGeneration;
class GCMemoryManager;
class ContiguousSpace;
class OopClosure;
class GCStats;
class Generation: public CHeapObj<mtGC> {
friend class VMStructs;
@ -73,9 +71,6 @@ class Generation: public CHeapObj<mtGC> {
// Performance Counters
CollectorCounters* _gc_counters;
// Statistics for garbage collection
GCStats* _gc_stats;
// Initialize the generation.
Generation(ReservedSpace rs, size_t initial_byte_size);
@ -168,15 +163,6 @@ class Generation: public CHeapObj<mtGC> {
// still unsuccessful, return "null".
virtual HeapWord* expand_and_allocate(size_t word_size, bool is_tlab) = 0;
// Generations may keep statistics about collection. This method
// updates those statistics. current_generation is the generation
// that was most recently collected. This allows the generation to
// decide what statistics are valid to collect. For example, the
// generation can decide to gather the amount of promoted data if
// the collection of the young generation has completed.
GCStats* gc_stats() const { return _gc_stats; }
virtual void update_gc_stats(Generation* current_generation, bool full) {}
// Printing
virtual const char* name() const = 0;
virtual const char* short_name() const = 0;

View File

@ -308,7 +308,7 @@ TenuredGeneration::TenuredGeneration(ReservedSpace rs,
_shrink_factor = ShrinkHeapInSteps ? 0 : 100;
_capacity_at_prologue = 0;
_gc_stats = new GCStats();
_avg_promoted = new AdaptivePaddedNoZeroDevAverage(AdaptiveSizePolicyWeight, PromotedPadding);
// initialize performance counters
@ -390,7 +390,7 @@ void TenuredGeneration::update_gc_stats(Generation* current_generation,
// also possible that no promotion was needed.
if (used_before_gc >= _used_at_prologue) {
size_t promoted_in_bytes = used_before_gc - _used_at_prologue;
gc_stats()->avg_promoted()->sample(promoted_in_bytes);
_avg_promoted->sample(promoted_in_bytes);
}
}
}
@ -404,7 +404,7 @@ void TenuredGeneration::update_counters() {
bool TenuredGeneration::promotion_attempt_is_safe(size_t max_promotion_in_bytes) const {
size_t available = max_contiguous_available();
size_t av_promo = (size_t)gc_stats()->avg_promoted()->padded_average();
size_t av_promo = (size_t)_avg_promoted->padded_average();
bool res = (available >= av_promo) || (available >= max_promotion_in_bytes);
log_trace(gc)("Tenured: promo attempt is%s safe: available(" SIZE_FORMAT ") %s av_promo(" SIZE_FORMAT "), max_promo(" SIZE_FORMAT ")",

View File

@ -27,7 +27,6 @@
#include "gc/serial/cSpaceCounters.hpp"
#include "gc/serial/generation.hpp"
#include "gc/shared/gcStats.hpp"
#include "gc/shared/generationCounters.hpp"
#include "gc/shared/space.hpp"
#include "utilities/macros.hpp"
@ -71,6 +70,10 @@ class TenuredGeneration: public Generation {
GenerationCounters* _gen_counters;
CSpaceCounters* _space_counters;
// Avg amount promoted; used for avoiding promotion undo
// This class does not update deviations if the sample is zero.
AdaptivePaddedNoZeroDevAverage* _avg_promoted;
// Attempt to expand the generation by "bytes". Expand by at a
// minimum "expand_bytes". Return true if some amount (not
// necessarily the full "bytes") was done.
@ -80,7 +83,8 @@ class TenuredGeneration: public Generation {
void shrink(size_t bytes);
void compute_new_size_inner();
public:
public:
void compute_new_size();
TenuredSpace* space() const { return _the_space; }
@ -158,7 +162,7 @@ class TenuredGeneration: public Generation {
// Statistics
virtual void update_gc_stats(Generation* current_generation, bool full);
void update_gc_stats(Generation* current_generation, bool full);
// Returns true if promotions of the specified amount are
// likely to succeed without a promotion failure.

View File

@ -1,30 +0,0 @@
/*
* Copyright (c) 2003, 2021, 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.
*
*/
#include "precompiled.hpp"
#include "gc/shared/gcStats.hpp"
#include "gc/shared/gcUtil.hpp"
#include "gc/shared/gc_globals.hpp"
GCStats::GCStats() : _avg_promoted(new AdaptivePaddedNoZeroDevAverage(AdaptiveSizePolicyWeight, PromotedPadding)) {}

View File

@ -1,42 +0,0 @@
/*
* Copyright (c) 2003, 2019, 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.
*
*/
#ifndef SHARE_GC_SHARED_GCSTATS_HPP
#define SHARE_GC_SHARED_GCSTATS_HPP
#include "gc/shared/gcUtil.hpp"
class GCStats : public CHeapObj<mtGC> {
protected:
// Avg amount promoted; used for avoiding promotion undo
// This class does not update deviations if the sample is zero.
AdaptivePaddedNoZeroDevAverage* _avg_promoted;
public:
GCStats();
AdaptivePaddedNoZeroDevAverage* avg_promoted() const { return _avg_promoted; }
};
#endif // SHARE_GC_SHARED_GCSTATS_HPP