8286189: G1: Change "wasted" memory to "unused" memory in reporting

Reviewed-by: iwalulya, ayang
This commit is contained in:
Thomas Schatzl 2022-05-06 12:45:35 +00:00
parent c6eab989b7
commit b9f4370325
8 changed files with 38 additions and 36 deletions

View File

@ -909,8 +909,8 @@ size_t G1CardSet::mem_size() const {
_mm->mem_size(); _mm->mem_size();
} }
size_t G1CardSet::wasted_mem_size() const { size_t G1CardSet::unused_mem_size() const {
return _mm->wasted_mem_size(); return _mm->unused_mem_size();
} }
size_t G1CardSet::static_mem_size() { size_t G1CardSet::static_mem_size() {

View File

@ -324,7 +324,7 @@ public:
// Returns size of the actual remembered set containers in bytes. // Returns size of the actual remembered set containers in bytes.
size_t mem_size() const; size_t mem_size() const;
size_t wasted_mem_size() const; size_t unused_mem_size() const;
// Returns the size of static data in bytes. // Returns the size of static data in bytes.
static size_t static_mem_size(); static size_t static_mem_size();

View File

@ -57,14 +57,14 @@ void G1CardSetAllocator::drop_all() {
size_t G1CardSetAllocator::mem_size() const { size_t G1CardSetAllocator::mem_size() const {
return sizeof(*this) + return sizeof(*this) +
_segmented_array.num_segments() * sizeof(G1CardSetSegment) + _segmented_array.num_segments() * sizeof(G1CardSetSegment) +
_segmented_array.num_available_slots() * _segmented_array.slot_size(); _segmented_array.num_total_slots() * _segmented_array.slot_size();
} }
size_t G1CardSetAllocator::wasted_mem_size() const { size_t G1CardSetAllocator::unused_mem_size() const {
uint num_wasted_slots = _segmented_array.num_available_slots() - uint num_unused_slots = _segmented_array.num_total_slots() -
_segmented_array.num_allocated_slots() - _segmented_array.num_allocated_slots() -
(uint)_free_slots_list.pending_count(); (uint)_free_slots_list.pending_count();
return num_wasted_slots * _segmented_array.slot_size(); return num_unused_slots * _segmented_array.slot_size();
} }
uint G1CardSetAllocator::num_segments() const { uint G1CardSetAllocator::num_segments() const {
@ -73,18 +73,18 @@ uint G1CardSetAllocator::num_segments() const {
void G1CardSetAllocator::print(outputStream* os) { void G1CardSetAllocator::print(outputStream* os) {
uint num_allocated_slots = _segmented_array.num_allocated_slots(); uint num_allocated_slots = _segmented_array.num_allocated_slots();
uint num_available_slots = _segmented_array.num_available_slots(); uint num_total_slots = _segmented_array.num_total_slots();
uint highest = _segmented_array.first_array_segment() != nullptr uint highest = _segmented_array.first_array_segment() != nullptr
? _segmented_array.first_array_segment()->num_slots() ? _segmented_array.first_array_segment()->num_slots()
: 0; : 0;
uint num_segments = _segmented_array.num_segments(); uint num_segments = _segmented_array.num_segments();
uint num_pending_slots = (uint)_free_slots_list.pending_count(); uint num_pending_slots = (uint)_free_slots_list.pending_count();
os->print("MA " PTR_FORMAT ": %u slots pending (allocated %u available %u) used %.3f highest %u segments %u size %zu ", os->print("MA " PTR_FORMAT ": %u slots pending (allocated %u total %u) used %.3f highest %u segments %u size %zu ",
p2i(this), p2i(this),
num_pending_slots, num_pending_slots,
num_allocated_slots, num_allocated_slots,
num_available_slots, num_total_slots,
percent_of(num_allocated_slots - num_pending_slots, num_available_slots), percent_of(num_allocated_slots - num_pending_slots, num_total_slots),
highest, highest,
num_segments, num_segments,
mem_size()); mem_size());
@ -142,10 +142,10 @@ size_t G1CardSetMemoryManager::mem_size() const {
(sizeof(G1CardSetAllocator) * num_mem_object_types()); (sizeof(G1CardSetAllocator) * num_mem_object_types());
} }
size_t G1CardSetMemoryManager::wasted_mem_size() const { size_t G1CardSetMemoryManager::unused_mem_size() const {
size_t result = 0; size_t result = 0;
for (uint i = 0; i < num_mem_object_types(); i++) { for (uint i = 0; i < num_mem_object_types(); i++) {
result += _allocators[i].wasted_mem_size(); result += _allocators[i].unused_mem_size();
} }
return result; return result;
} }

View File

@ -83,9 +83,11 @@ public:
// be called in a globally synchronized area. // be called in a globally synchronized area.
void drop_all(); void drop_all();
// Total memory allocated.
size_t mem_size() const; size_t mem_size() const;
size_t wasted_mem_size() const; // Unused (but usable) memory.
size_t unused_mem_size() const;
uint num_segments() const; uint num_segments() const;
@ -119,7 +121,7 @@ public:
void print(outputStream* os); void print(outputStream* os);
size_t mem_size() const; size_t mem_size() const;
size_t wasted_mem_size() const; size_t unused_mem_size() const;
G1SegmentedArrayMemoryStats memory_stats() const; G1SegmentedArrayMemoryStats memory_stats() const;
}; };

View File

@ -114,7 +114,7 @@ class RegionTypeCounter {
private: private:
const char* _name; const char* _name;
size_t _rs_wasted_mem_size; size_t _rs_unused_mem_size;
size_t _rs_mem_size; size_t _rs_mem_size;
size_t _cards_occupied; size_t _cards_occupied;
size_t _amount; size_t _amount;
@ -144,12 +144,12 @@ private:
public: public:
RegionTypeCounter(const char* name) : _name(name), _rs_wasted_mem_size(0), _rs_mem_size(0), _cards_occupied(0), RegionTypeCounter(const char* name) : _name(name), _rs_unused_mem_size(0), _rs_mem_size(0), _cards_occupied(0),
_amount(0), _amount_tracked(0), _code_root_mem_size(0), _code_root_elems(0) { } _amount(0), _amount_tracked(0), _code_root_mem_size(0), _code_root_elems(0) { }
void add(size_t rs_wasted_mem_size, size_t rs_mem_size, size_t cards_occupied, void add(size_t rs_unused_mem_size, size_t rs_mem_size, size_t cards_occupied,
size_t code_root_mem_size, size_t code_root_elems, bool tracked) { size_t code_root_mem_size, size_t code_root_elems, bool tracked) {
_rs_wasted_mem_size += rs_wasted_mem_size; _rs_unused_mem_size += rs_unused_mem_size;
_rs_mem_size += rs_mem_size; _rs_mem_size += rs_mem_size;
_cards_occupied += cards_occupied; _cards_occupied += cards_occupied;
_code_root_mem_size += code_root_mem_size; _code_root_mem_size += code_root_mem_size;
@ -158,7 +158,7 @@ public:
_amount_tracked += tracked ? 1 : 0; _amount_tracked += tracked ? 1 : 0;
} }
size_t rs_wasted_mem_size() const { return _rs_wasted_mem_size; } size_t rs_unused_mem_size() const { return _rs_unused_mem_size; }
size_t rs_mem_size() const { return _rs_mem_size; } size_t rs_mem_size() const { return _rs_mem_size; }
size_t cards_occupied() const { return _cards_occupied; } size_t cards_occupied() const { return _cards_occupied; }
@ -167,10 +167,10 @@ public:
void print_rs_mem_info_on(outputStream * out, size_t total) { void print_rs_mem_info_on(outputStream * out, size_t total) {
out->print_cr(" " SIZE_FORMAT_W(8) " (%5.1f%%) by " SIZE_FORMAT " " out->print_cr(" " SIZE_FORMAT_W(8) " (%5.1f%%) by " SIZE_FORMAT " "
"(" SIZE_FORMAT ") %s regions wasted " SIZE_FORMAT, "(" SIZE_FORMAT ") %s regions unused " SIZE_FORMAT,
rs_mem_size(), rs_mem_size_percent_of(total), rs_mem_size(), rs_mem_size_percent_of(total),
amount_tracked(), amount(), amount_tracked(), amount(),
_name, rs_wasted_mem_size()); _name, rs_unused_mem_size());
} }
void print_cards_occupied_info_on(outputStream * out, size_t total) { void print_cards_occupied_info_on(outputStream * out, size_t total) {
@ -206,7 +206,7 @@ private:
size_t _max_rs_mem_sz; size_t _max_rs_mem_sz;
HeapRegion* _max_rs_mem_sz_region; HeapRegion* _max_rs_mem_sz_region;
size_t total_rs_wasted_mem_sz() const { return _all.rs_wasted_mem_size(); } size_t total_rs_unused_mem_sz() const { return _all.rs_unused_mem_size(); }
size_t total_rs_mem_sz() const { return _all.rs_mem_size(); } size_t total_rs_mem_sz() const { return _all.rs_mem_size(); }
size_t total_cards_occupied() const { return _all.cards_occupied(); } size_t total_cards_occupied() const { return _all.cards_occupied(); }
@ -234,7 +234,7 @@ public:
// HeapRegionRemSet::mem_size() includes the // HeapRegionRemSet::mem_size() includes the
// size of the code roots // size of the code roots
size_t rs_wasted_mem_sz = hrrs->wasted_mem_size(); size_t rs_unused_mem_sz = hrrs->unused_mem_size();
size_t rs_mem_sz = hrrs->mem_size(); size_t rs_mem_sz = hrrs->mem_size();
if (rs_mem_sz > _max_rs_mem_sz) { if (rs_mem_sz > _max_rs_mem_sz) {
_max_rs_mem_sz = rs_mem_sz; _max_rs_mem_sz = rs_mem_sz;
@ -262,9 +262,9 @@ public:
} else { } else {
ShouldNotReachHere(); ShouldNotReachHere();
} }
current->add(rs_wasted_mem_sz, rs_mem_sz, occupied_cards, current->add(rs_unused_mem_sz, rs_mem_sz, occupied_cards,
code_root_mem_sz, code_root_elems, r->rem_set()->is_tracked()); code_root_mem_sz, code_root_elems, r->rem_set()->is_tracked());
_all.add(rs_wasted_mem_sz, rs_mem_sz, occupied_cards, _all.add(rs_unused_mem_sz, rs_mem_sz, occupied_cards,
code_root_mem_sz, code_root_elems, r->rem_set()->is_tracked()); code_root_mem_sz, code_root_elems, r->rem_set()->is_tracked());
return false; return false;
@ -275,10 +275,10 @@ public:
out->print_cr(" Current rem set statistics"); out->print_cr(" Current rem set statistics");
out->print_cr(" Total per region rem sets sizes = " SIZE_FORMAT out->print_cr(" Total per region rem sets sizes = " SIZE_FORMAT
" Max = " SIZE_FORMAT " wasted = " SIZE_FORMAT, " Max = " SIZE_FORMAT " unused = " SIZE_FORMAT,
total_rs_mem_sz(), total_rs_mem_sz(),
max_rs_mem_sz(), max_rs_mem_sz(),
total_rs_wasted_mem_sz()); total_rs_unused_mem_sz());
for (RegionTypeCounter** current = &counters[0]; *current != NULL; current++) { for (RegionTypeCounter** current = &counters[0]; *current != NULL; current++) {
(*current)->print_rs_mem_info_on(out, total_rs_mem_sz()); (*current)->print_rs_mem_info_on(out, total_rs_mem_sz());
} }

View File

@ -124,7 +124,7 @@ G1SegmentedArraySegment* G1SegmentedArray::create_new_segment(G1SegmentedArraySe
// Successfully installed the segment into the list. // Successfully installed the segment into the list.
Atomic::inc(&_num_segments, memory_order_relaxed); Atomic::inc(&_num_segments, memory_order_relaxed);
Atomic::add(&_mem_size, next->mem_size(), memory_order_relaxed); Atomic::add(&_mem_size, next->mem_size(), memory_order_relaxed);
Atomic::add(&_num_available_slots, next->num_slots(), memory_order_relaxed); Atomic::add(&_num_total_slots, next->num_slots(), memory_order_relaxed);
return next; return next;
} }
} }
@ -137,7 +137,7 @@ G1SegmentedArray::G1SegmentedArray(const G1SegmentedArrayAllocOptions* alloc_opt
_num_segments(0), _num_segments(0),
_mem_size(0), _mem_size(0),
_free_segment_list(free_segment_list), _free_segment_list(free_segment_list),
_num_available_slots(0), _num_total_slots(0),
_num_allocated_slots(0) { _num_allocated_slots(0) {
assert(_free_segment_list != nullptr, "precondition!"); assert(_free_segment_list != nullptr, "precondition!");
} }
@ -182,7 +182,7 @@ void G1SegmentedArray::drop_all() {
_last = nullptr; _last = nullptr;
_num_segments = 0; _num_segments = 0;
_mem_size = 0; _mem_size = 0;
_num_available_slots = 0; _num_total_slots = 0;
_num_allocated_slots = 0; _num_allocated_slots = 0;
} }

View File

@ -215,8 +215,8 @@ class G1SegmentedArray : public FreeListConfig {
G1SegmentedArrayFreeList* _free_segment_list; // The global free segment list to preferentially G1SegmentedArrayFreeList* _free_segment_list; // The global free segment list to preferentially
// get new segments from. // get new segments from.
volatile uint _num_available_slots; // Number of slots available in all segments (allocated + free + pending + not yet used). volatile uint _num_total_slots; // Number of slots available in all segments (allocated + not yet used).
volatile uint _num_allocated_slots; // Number of total slots allocated and in use. volatile uint _num_allocated_slots; // Number of total slots allocated ever (including free and pending).
private: private:
inline G1SegmentedArraySegment* create_new_segment(G1SegmentedArraySegment* const prev); inline G1SegmentedArraySegment* create_new_segment(G1SegmentedArraySegment* const prev);
@ -226,7 +226,7 @@ private:
public: public:
const G1SegmentedArraySegment* first_array_segment() const { return Atomic::load(&_first); } const G1SegmentedArraySegment* first_array_segment() const { return Atomic::load(&_first); }
uint num_available_slots() const { return Atomic::load(&_num_available_slots); } uint num_total_slots() const { return Atomic::load(&_num_total_slots); }
uint num_allocated_slots() const { uint num_allocated_slots() const {
uint allocated = Atomic::load(&_num_allocated_slots); uint allocated = Atomic::load(&_num_allocated_slots);
assert(calculate_length() == allocated, "Must be"); assert(calculate_length() == allocated, "Must be");

View File

@ -136,8 +136,8 @@ public:
+ code_roots_mem_size(); + code_roots_mem_size();
} }
size_t wasted_mem_size() { size_t unused_mem_size() {
return _card_set.wasted_mem_size(); return _card_set.unused_mem_size();
} }
// Returns the memory occupancy of all static data structures associated // Returns the memory occupancy of all static data structures associated