8256484: ZGC: Rename ZRelocationSetSelector::register_garbage_page()

Reviewed-by: stefank, ayang
This commit is contained in:
Per Liden 2020-11-17 20:48:14 +00:00
parent d9dbd5def6
commit f751738645
5 changed files with 46 additions and 46 deletions

View File

@ -361,13 +361,13 @@ void ZHeap::process_non_strong_references() {
_reference_processor.enqueue_references(); _reference_processor.enqueue_references();
} }
void ZHeap::free_garbage_pages(ZRelocationSetSelector* selector, int bulk) { void ZHeap::free_empty_pages(ZRelocationSetSelector* selector, int bulk) {
// Freeing garbage pages in bulk is an optimization to avoid grabbing // Freeing empty pages in bulk is an optimization to avoid grabbing
// the page allocator lock, and trying to satisfy stalled allocations // the page allocator lock, and trying to satisfy stalled allocations
// too frequently. // too frequently.
if (selector->should_free_garbage_pages(bulk)) { if (selector->should_free_empty_pages(bulk)) {
free_pages(selector->garbage_pages(), true /* reclaimed */); free_pages(selector->empty_pages(), true /* reclaimed */);
selector->clear_garbage_pages(); selector->clear_empty_pages();
} }
} }
@ -388,16 +388,16 @@ void ZHeap::select_relocation_set() {
// Register live page // Register live page
selector.register_live_page(page); selector.register_live_page(page);
} else { } else {
// Register garbage page // Register empty page
selector.register_garbage_page(page); selector.register_empty_page(page);
// Reclaim garbage pages in bulk // Reclaim empty pages in bulk
free_garbage_pages(&selector, 64 /* bulk */); free_empty_pages(&selector, 64 /* bulk */);
} }
} }
// Reclaim remaining garbage pages // Reclaim remaining empty pages
free_garbage_pages(&selector, 0 /* bulk */); free_empty_pages(&selector, 0 /* bulk */);
// Allow pages to be deleted // Allow pages to be deleted
_page_allocator.disable_deferred_delete(); _page_allocator.disable_deferred_delete();

View File

@ -65,7 +65,7 @@ private:
void flip_to_marked(); void flip_to_marked();
void flip_to_remapped(); void flip_to_remapped();
void free_garbage_pages(ZRelocationSetSelector* selector, int bulk); void free_empty_pages(ZRelocationSetSelector* selector, int bulk);
void out_of_memory(); void out_of_memory();

View File

@ -50,7 +50,7 @@ ZRelocationSetSelectorGroup::ZRelocationSetSelectorGroup(const char* name,
_page_size(page_size), _page_size(page_size),
_object_size_limit(object_size_limit), _object_size_limit(object_size_limit),
_fragmentation_limit(page_size * (ZFragmentationLimit / 100)), _fragmentation_limit(page_size * (ZFragmentationLimit / 100)),
_registered_pages(), _live_pages(),
_forwarding_entries(0), _forwarding_entries(0),
_stats() {} _stats() {}
@ -65,7 +65,7 @@ bool ZRelocationSetSelectorGroup::is_selectable() {
} }
void ZRelocationSetSelectorGroup::semi_sort() { void ZRelocationSetSelectorGroup::semi_sort() {
// Semi-sort registered pages by live bytes in ascending order // Semi-sort live pages by number of live bytes in ascending order
const size_t npartitions_shift = 11; const size_t npartitions_shift = 11;
const size_t npartitions = (size_t)1 << npartitions_shift; const size_t npartitions = (size_t)1 << npartitions_shift;
const size_t partition_size = _page_size >> npartitions_shift; const size_t partition_size = _page_size >> npartitions_shift;
@ -75,7 +75,7 @@ void ZRelocationSetSelectorGroup::semi_sort() {
int partitions[npartitions] = { /* zero initialize */ }; int partitions[npartitions] = { /* zero initialize */ };
// Calculate partition slots // Calculate partition slots
ZArrayIterator<ZPage*> iter1(&_registered_pages); ZArrayIterator<ZPage*> iter1(&_live_pages);
for (ZPage* page; iter1.next(&page);) { for (ZPage* page; iter1.next(&page);) {
const size_t index = page->live_bytes() >> partition_size_shift; const size_t index = page->live_bytes() >> partition_size_shift;
partitions[index]++; partitions[index]++;
@ -90,26 +90,26 @@ void ZRelocationSetSelectorGroup::semi_sort() {
} }
// Allocate destination array // Allocate destination array
const int npages = _registered_pages.length(); const int npages = _live_pages.length();
ZArray<ZPage*> sorted_pages(npages, npages, NULL); ZArray<ZPage*> sorted_live_pages(npages, npages, NULL);
// Sort pages into partitions // Sort pages into partitions
ZArrayIterator<ZPage*> iter2(&_registered_pages); ZArrayIterator<ZPage*> iter2(&_live_pages);
for (ZPage* page; iter2.next(&page);) { for (ZPage* page; iter2.next(&page);) {
const size_t index = page->live_bytes() >> partition_size_shift; const size_t index = page->live_bytes() >> partition_size_shift;
const int finger = partitions[index]++; const int finger = partitions[index]++;
assert(sorted_pages.at(finger) == NULL, "Invalid finger"); assert(sorted_live_pages.at(finger) == NULL, "Invalid finger");
sorted_pages.at_put(finger, page); sorted_live_pages.at_put(finger, page);
} }
_registered_pages.swap(&sorted_pages); _live_pages.swap(&sorted_live_pages);
} }
void ZRelocationSetSelectorGroup::select_inner() { void ZRelocationSetSelectorGroup::select_inner() {
// Calculate the number of pages to relocate by successively including pages in // Calculate the number of pages to relocate by successively including pages in
// a candidate relocation set and calculate the maximum space requirement for // a candidate relocation set and calculate the maximum space requirement for
// their live objects. // their live objects.
const int npages = _registered_pages.length(); const int npages = _live_pages.length();
int selected_from = 0; int selected_from = 0;
int selected_to = 0; int selected_to = 0;
size_t selected_forwarding_entries = 0; size_t selected_forwarding_entries = 0;
@ -120,7 +120,7 @@ void ZRelocationSetSelectorGroup::select_inner() {
for (int from = 1; from <= npages; from++) { for (int from = 1; from <= npages; from++) {
// Add page to the candidate relocation set // Add page to the candidate relocation set
ZPage* const page = _registered_pages.at(from - 1); ZPage* const page = _live_pages.at(from - 1);
from_live_bytes += page->live_bytes(); from_live_bytes += page->live_bytes();
from_forwarding_entries += ZForwarding::nentries(page); from_forwarding_entries += ZForwarding::nentries(page);
@ -150,7 +150,7 @@ void ZRelocationSetSelectorGroup::select_inner() {
} }
// Finalize selection // Finalize selection
_registered_pages.trunc_to(selected_from); _live_pages.trunc_to(selected_from);
_forwarding_entries = selected_forwarding_entries; _forwarding_entries = selected_forwarding_entries;
// Update statistics // Update statistics
@ -181,7 +181,7 @@ ZRelocationSetSelector::ZRelocationSetSelector() :
_small("Small", ZPageTypeSmall, ZPageSizeSmall, ZObjectSizeLimitSmall), _small("Small", ZPageTypeSmall, ZPageSizeSmall, ZObjectSizeLimitSmall),
_medium("Medium", ZPageTypeMedium, ZPageSizeMedium, ZObjectSizeLimitMedium), _medium("Medium", ZPageTypeMedium, ZPageSizeMedium, ZObjectSizeLimitMedium),
_large("Large", ZPageTypeLarge, 0 /* page_size */, 0 /* object_size_limit */), _large("Large", ZPageTypeLarge, 0 /* page_size */, 0 /* object_size_limit */),
_garbage_pages() {} _empty_pages() {}
void ZRelocationSetSelector::select() { void ZRelocationSetSelector::select() {
// Select pages to relocate. The resulting relocation set will be // Select pages to relocate. The resulting relocation set will be

View File

@ -74,7 +74,7 @@ private:
const size_t _page_size; const size_t _page_size;
const size_t _object_size_limit; const size_t _object_size_limit;
const size_t _fragmentation_limit; const size_t _fragmentation_limit;
ZArray<ZPage*> _registered_pages; ZArray<ZPage*> _live_pages;
size_t _forwarding_entries; size_t _forwarding_entries;
ZRelocationSetSelectorGroupStats _stats; ZRelocationSetSelectorGroupStats _stats;
@ -90,7 +90,7 @@ public:
size_t object_size_limit); size_t object_size_limit);
void register_live_page(ZPage* page); void register_live_page(ZPage* page);
void register_garbage_page(ZPage* page); void register_empty_page(ZPage* page);
void select(); void select();
const ZArray<ZPage*>* selected() const; const ZArray<ZPage*>* selected() const;
@ -104,7 +104,7 @@ private:
ZRelocationSetSelectorGroup _small; ZRelocationSetSelectorGroup _small;
ZRelocationSetSelectorGroup _medium; ZRelocationSetSelectorGroup _medium;
ZRelocationSetSelectorGroup _large; ZRelocationSetSelectorGroup _large;
ZArray<ZPage*> _garbage_pages; ZArray<ZPage*> _empty_pages;
size_t total() const; size_t total() const;
size_t empty() const; size_t empty() const;
@ -115,11 +115,11 @@ public:
ZRelocationSetSelector(); ZRelocationSetSelector();
void register_live_page(ZPage* page); void register_live_page(ZPage* page);
void register_garbage_page(ZPage* page); void register_empty_page(ZPage* page);
bool should_free_garbage_pages(int bulk) const; bool should_free_empty_pages(int bulk) const;
const ZArray<ZPage*>* garbage_pages() const; const ZArray<ZPage*>* empty_pages() const;
void clear_garbage_pages(); void clear_empty_pages();
void select(); void select();

View File

@ -75,7 +75,7 @@ inline void ZRelocationSetSelectorGroup::register_live_page(ZPage* page) {
const size_t garbage = size - live; const size_t garbage = size - live;
if (garbage > _fragmentation_limit) { if (garbage > _fragmentation_limit) {
_registered_pages.append(page); _live_pages.append(page);
} }
_stats._npages++; _stats._npages++;
@ -84,7 +84,7 @@ inline void ZRelocationSetSelectorGroup::register_live_page(ZPage* page) {
_stats._garbage += garbage; _stats._garbage += garbage;
} }
inline void ZRelocationSetSelectorGroup::register_garbage_page(ZPage* page) { inline void ZRelocationSetSelectorGroup::register_empty_page(ZPage* page) {
const size_t size = page->size(); const size_t size = page->size();
_stats._npages++; _stats._npages++;
@ -94,7 +94,7 @@ inline void ZRelocationSetSelectorGroup::register_garbage_page(ZPage* page) {
} }
inline const ZArray<ZPage*>* ZRelocationSetSelectorGroup::selected() const { inline const ZArray<ZPage*>* ZRelocationSetSelectorGroup::selected() const {
return &_registered_pages; return &_live_pages;
} }
inline size_t ZRelocationSetSelectorGroup::forwarding_entries() const { inline size_t ZRelocationSetSelectorGroup::forwarding_entries() const {
@ -117,30 +117,30 @@ inline void ZRelocationSetSelector::register_live_page(ZPage* page) {
} }
} }
inline void ZRelocationSetSelector::register_garbage_page(ZPage* page) { inline void ZRelocationSetSelector::register_empty_page(ZPage* page) {
const uint8_t type = page->type(); const uint8_t type = page->type();
if (type == ZPageTypeSmall) { if (type == ZPageTypeSmall) {
_small.register_garbage_page(page); _small.register_empty_page(page);
} else if (type == ZPageTypeMedium) { } else if (type == ZPageTypeMedium) {
_medium.register_garbage_page(page); _medium.register_empty_page(page);
} else { } else {
_large.register_garbage_page(page); _large.register_empty_page(page);
} }
_garbage_pages.append(page); _empty_pages.append(page);
} }
inline bool ZRelocationSetSelector::should_free_garbage_pages(int bulk) const { inline bool ZRelocationSetSelector::should_free_empty_pages(int bulk) const {
return _garbage_pages.length() >= bulk && _garbage_pages.is_nonempty(); return _empty_pages.length() >= bulk && _empty_pages.is_nonempty();
} }
inline const ZArray<ZPage*>* ZRelocationSetSelector::garbage_pages() const { inline const ZArray<ZPage*>* ZRelocationSetSelector::empty_pages() const {
return &_garbage_pages; return &_empty_pages;
} }
inline void ZRelocationSetSelector::clear_garbage_pages() { inline void ZRelocationSetSelector::clear_empty_pages() {
return _garbage_pages.clear(); return _empty_pages.clear();
} }
inline size_t ZRelocationSetSelector::total() const { inline size_t ZRelocationSetSelector::total() const {