mirror of
https://github.com/openjdk/jdk.git
synced 2026-01-28 03:58:21 +00:00
8375971: G1: Convert G1EvacStats to use Atomic<T>
Reviewed-by: iwalulya, kbarrett
This commit is contained in:
parent
c3360ff511
commit
0bc2dc3401
@ -31,6 +31,7 @@
|
||||
#include "gc/g1/g1CollectorState.hpp"
|
||||
#include "gc/g1/g1ConcurrentMark.inline.hpp"
|
||||
#include "gc/g1/g1EvacFailureRegions.hpp"
|
||||
#include "gc/g1/g1EvacStats.inline.hpp"
|
||||
#include "gc/g1/g1HeapRegion.inline.hpp"
|
||||
#include "gc/g1/g1HeapRegionManager.inline.hpp"
|
||||
#include "gc/g1/g1HeapRegionRemSet.hpp"
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2015, 2025, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2015, 2026, 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
|
||||
@ -22,13 +22,24 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "gc/g1/g1EvacStats.hpp"
|
||||
#include "gc/g1/g1EvacStats.inline.hpp"
|
||||
#include "gc/shared/gc_globals.hpp"
|
||||
#include "gc/shared/gcId.hpp"
|
||||
#include "logging/log.hpp"
|
||||
#include "memory/allocation.inline.hpp"
|
||||
#include "runtime/globals.hpp"
|
||||
|
||||
void G1EvacStats::reset() {
|
||||
PLABStats::reset();
|
||||
_region_end_waste.store_relaxed(0);
|
||||
_regions_filled.store_relaxed(0);
|
||||
_num_plab_filled.store_relaxed(0);
|
||||
_direct_allocated.store_relaxed(0);
|
||||
_num_direct_allocated.store_relaxed(0);
|
||||
_failure_used.store_relaxed(0);
|
||||
_failure_waste.store_relaxed(0);
|
||||
}
|
||||
|
||||
void G1EvacStats::log_plab_allocation() {
|
||||
log_debug(gc, plab)("%s PLAB allocation: "
|
||||
"allocated: %zuB, "
|
||||
@ -51,13 +62,13 @@ void G1EvacStats::log_plab_allocation() {
|
||||
"failure used: %zuB, "
|
||||
"failure wasted: %zuB",
|
||||
_description,
|
||||
_region_end_waste * HeapWordSize,
|
||||
_regions_filled,
|
||||
_num_plab_filled,
|
||||
_direct_allocated * HeapWordSize,
|
||||
_num_direct_allocated,
|
||||
_failure_used * HeapWordSize,
|
||||
_failure_waste * HeapWordSize);
|
||||
region_end_waste() * HeapWordSize,
|
||||
regions_filled(),
|
||||
num_plab_filled(),
|
||||
direct_allocated() * HeapWordSize,
|
||||
num_direct_allocated(),
|
||||
failure_used() * HeapWordSize,
|
||||
failure_waste() * HeapWordSize);
|
||||
}
|
||||
|
||||
void G1EvacStats::log_sizing(size_t calculated_words, size_t net_desired_words) {
|
||||
@ -109,7 +120,7 @@ size_t G1EvacStats::compute_desired_plab_size() const {
|
||||
// threads do not allocate anything but a few rather large objects. In this
|
||||
// degenerate case the PLAB size would simply quickly tend to minimum PLAB size,
|
||||
// which is an okay reaction.
|
||||
size_t const used_for_waste_calculation = used() > _region_end_waste ? used() - _region_end_waste : 0;
|
||||
size_t const used_for_waste_calculation = used() > region_end_waste() ? used() - region_end_waste() : 0;
|
||||
|
||||
size_t const total_waste_allowed = used_for_waste_calculation * TargetPLABWastePct;
|
||||
return (size_t)((double)total_waste_allowed / (100 - G1LastPLABAverageOccupancy));
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2015, 2025, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2015, 2026, 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
|
||||
@ -27,6 +27,7 @@
|
||||
|
||||
#include "gc/shared/gcUtil.hpp"
|
||||
#include "gc/shared/plab.hpp"
|
||||
#include "runtime/atomic.hpp"
|
||||
|
||||
// Records various memory allocation statistics gathered during evacuation. All sizes
|
||||
// are in HeapWords.
|
||||
@ -36,30 +37,21 @@ class G1EvacStats : public PLABStats {
|
||||
AdaptiveWeightedAverage
|
||||
_net_plab_size_filter; // Integrator with decay
|
||||
|
||||
size_t _region_end_waste; // Number of words wasted due to skipping to the next region.
|
||||
uint _regions_filled; // Number of regions filled completely.
|
||||
size_t _num_plab_filled; // Number of PLABs filled and retired.
|
||||
size_t _direct_allocated; // Number of words allocated directly into the regions.
|
||||
size_t _num_direct_allocated; // Number of direct allocation attempts.
|
||||
Atomic<size_t> _region_end_waste; // Number of words wasted due to skipping to the next region.
|
||||
Atomic<uint> _regions_filled; // Number of regions filled completely.
|
||||
Atomic<size_t> _num_plab_filled; // Number of PLABs filled and retired.
|
||||
Atomic<size_t> _direct_allocated; // Number of words allocated directly into the regions.
|
||||
Atomic<size_t> _num_direct_allocated; // Number of direct allocation attempts.
|
||||
|
||||
// Number of words in live objects remaining in regions that ultimately suffered an
|
||||
// evacuation failure. This is used in the regions when the regions are made old regions.
|
||||
size_t _failure_used;
|
||||
Atomic<size_t> _failure_used;
|
||||
// Number of words wasted in regions which failed evacuation. This is the sum of space
|
||||
// for objects successfully copied out of the regions (now dead space) plus waste at the
|
||||
// end of regions.
|
||||
size_t _failure_waste;
|
||||
Atomic<size_t> _failure_waste;
|
||||
|
||||
virtual void reset() {
|
||||
PLABStats::reset();
|
||||
_region_end_waste = 0;
|
||||
_regions_filled = 0;
|
||||
_num_plab_filled = 0;
|
||||
_direct_allocated = 0;
|
||||
_num_direct_allocated = 0;
|
||||
_failure_used = 0;
|
||||
_failure_waste = 0;
|
||||
}
|
||||
virtual void reset();
|
||||
|
||||
void log_plab_allocation();
|
||||
void log_sizing(size_t calculated_words, size_t net_desired_words);
|
||||
@ -77,16 +69,16 @@ public:
|
||||
// Should be called at the end of a GC pause.
|
||||
void adjust_desired_plab_size();
|
||||
|
||||
uint regions_filled() const { return _regions_filled; }
|
||||
size_t num_plab_filled() const { return _num_plab_filled; }
|
||||
size_t region_end_waste() const { return _region_end_waste; }
|
||||
size_t direct_allocated() const { return _direct_allocated; }
|
||||
size_t num_direct_allocated() const { return _num_direct_allocated; }
|
||||
uint regions_filled() const;
|
||||
size_t num_plab_filled() const;
|
||||
size_t region_end_waste() const;
|
||||
size_t direct_allocated() const;
|
||||
size_t num_direct_allocated() const;
|
||||
|
||||
// Amount of space in heapwords used in the failing regions when an evacuation failure happens.
|
||||
size_t failure_used() const { return _failure_used; }
|
||||
size_t failure_used() const;
|
||||
// Amount of space in heapwords wasted (unused) in the failing regions when an evacuation failure happens.
|
||||
size_t failure_waste() const { return _failure_waste; }
|
||||
size_t failure_waste() const;
|
||||
|
||||
inline void add_num_plab_filled(size_t value);
|
||||
inline void add_direct_allocated(size_t value);
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2015, 2025, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2015, 2026, 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
|
||||
@ -27,28 +27,54 @@
|
||||
|
||||
#include "gc/g1/g1EvacStats.hpp"
|
||||
|
||||
#include "runtime/atomicAccess.hpp"
|
||||
inline uint G1EvacStats::regions_filled() const {
|
||||
return _regions_filled.load_relaxed();
|
||||
}
|
||||
|
||||
inline size_t G1EvacStats::num_plab_filled() const {
|
||||
return _num_plab_filled.load_relaxed();
|
||||
}
|
||||
|
||||
inline size_t G1EvacStats::region_end_waste() const {
|
||||
return _region_end_waste.load_relaxed();
|
||||
}
|
||||
|
||||
inline size_t G1EvacStats::direct_allocated() const {
|
||||
return _direct_allocated.load_relaxed();
|
||||
}
|
||||
|
||||
inline size_t G1EvacStats::num_direct_allocated() const {
|
||||
return _num_direct_allocated.load_relaxed();
|
||||
}
|
||||
|
||||
inline size_t G1EvacStats::failure_used() const {
|
||||
return _failure_used.load_relaxed();
|
||||
}
|
||||
|
||||
inline size_t G1EvacStats::failure_waste() const {
|
||||
return _failure_waste.load_relaxed();
|
||||
}
|
||||
|
||||
inline void G1EvacStats::add_direct_allocated(size_t value) {
|
||||
AtomicAccess::add(&_direct_allocated, value, memory_order_relaxed);
|
||||
_direct_allocated.add_then_fetch(value, memory_order_relaxed);
|
||||
}
|
||||
|
||||
inline void G1EvacStats::add_num_plab_filled(size_t value) {
|
||||
AtomicAccess::add(&_num_plab_filled, value, memory_order_relaxed);
|
||||
_num_plab_filled.add_then_fetch(value, memory_order_relaxed);
|
||||
}
|
||||
|
||||
inline void G1EvacStats::add_num_direct_allocated(size_t value) {
|
||||
AtomicAccess::add(&_num_direct_allocated, value, memory_order_relaxed);
|
||||
_num_direct_allocated.add_then_fetch(value, memory_order_relaxed);
|
||||
}
|
||||
|
||||
inline void G1EvacStats::add_region_end_waste(size_t value) {
|
||||
AtomicAccess::add(&_region_end_waste, value, memory_order_relaxed);
|
||||
AtomicAccess::inc(&_regions_filled, memory_order_relaxed);
|
||||
_region_end_waste.add_then_fetch(value, memory_order_relaxed);
|
||||
_regions_filled.add_then_fetch(1u, memory_order_relaxed);
|
||||
}
|
||||
|
||||
inline void G1EvacStats::add_failure_used_and_waste(size_t used, size_t waste) {
|
||||
AtomicAccess::add(&_failure_used, used, memory_order_relaxed);
|
||||
AtomicAccess::add(&_failure_waste, waste, memory_order_relaxed);
|
||||
_failure_used.add_then_fetch(used, memory_order_relaxed);
|
||||
_failure_waste.add_then_fetch(waste, memory_order_relaxed);
|
||||
}
|
||||
|
||||
#endif // SHARE_GC_G1_G1EVACSTATS_INLINE_HPP
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user