8256484: ZGC: Rename ZRelocationSetSelector::register_garbage_page()
Reviewed-by: stefank, ayang
This commit is contained in:
parent
d9dbd5def6
commit
f751738645
@ -361,13 +361,13 @@ void ZHeap::process_non_strong_references() {
|
||||
_reference_processor.enqueue_references();
|
||||
}
|
||||
|
||||
void ZHeap::free_garbage_pages(ZRelocationSetSelector* selector, int bulk) {
|
||||
// Freeing garbage pages in bulk is an optimization to avoid grabbing
|
||||
void ZHeap::free_empty_pages(ZRelocationSetSelector* selector, int bulk) {
|
||||
// Freeing empty pages in bulk is an optimization to avoid grabbing
|
||||
// the page allocator lock, and trying to satisfy stalled allocations
|
||||
// too frequently.
|
||||
if (selector->should_free_garbage_pages(bulk)) {
|
||||
free_pages(selector->garbage_pages(), true /* reclaimed */);
|
||||
selector->clear_garbage_pages();
|
||||
if (selector->should_free_empty_pages(bulk)) {
|
||||
free_pages(selector->empty_pages(), true /* reclaimed */);
|
||||
selector->clear_empty_pages();
|
||||
}
|
||||
}
|
||||
|
||||
@ -388,16 +388,16 @@ void ZHeap::select_relocation_set() {
|
||||
// Register live page
|
||||
selector.register_live_page(page);
|
||||
} else {
|
||||
// Register garbage page
|
||||
selector.register_garbage_page(page);
|
||||
// Register empty page
|
||||
selector.register_empty_page(page);
|
||||
|
||||
// Reclaim garbage pages in bulk
|
||||
free_garbage_pages(&selector, 64 /* bulk */);
|
||||
// Reclaim empty pages in bulk
|
||||
free_empty_pages(&selector, 64 /* bulk */);
|
||||
}
|
||||
}
|
||||
|
||||
// Reclaim remaining garbage pages
|
||||
free_garbage_pages(&selector, 0 /* bulk */);
|
||||
// Reclaim remaining empty pages
|
||||
free_empty_pages(&selector, 0 /* bulk */);
|
||||
|
||||
// Allow pages to be deleted
|
||||
_page_allocator.disable_deferred_delete();
|
||||
|
@ -65,7 +65,7 @@ private:
|
||||
void flip_to_marked();
|
||||
void flip_to_remapped();
|
||||
|
||||
void free_garbage_pages(ZRelocationSetSelector* selector, int bulk);
|
||||
void free_empty_pages(ZRelocationSetSelector* selector, int bulk);
|
||||
|
||||
void out_of_memory();
|
||||
|
||||
|
@ -50,7 +50,7 @@ ZRelocationSetSelectorGroup::ZRelocationSetSelectorGroup(const char* name,
|
||||
_page_size(page_size),
|
||||
_object_size_limit(object_size_limit),
|
||||
_fragmentation_limit(page_size * (ZFragmentationLimit / 100)),
|
||||
_registered_pages(),
|
||||
_live_pages(),
|
||||
_forwarding_entries(0),
|
||||
_stats() {}
|
||||
|
||||
@ -65,7 +65,7 @@ bool ZRelocationSetSelectorGroup::is_selectable() {
|
||||
}
|
||||
|
||||
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 = (size_t)1 << npartitions_shift;
|
||||
const size_t partition_size = _page_size >> npartitions_shift;
|
||||
@ -75,7 +75,7 @@ void ZRelocationSetSelectorGroup::semi_sort() {
|
||||
int partitions[npartitions] = { /* zero initialize */ };
|
||||
|
||||
// Calculate partition slots
|
||||
ZArrayIterator<ZPage*> iter1(&_registered_pages);
|
||||
ZArrayIterator<ZPage*> iter1(&_live_pages);
|
||||
for (ZPage* page; iter1.next(&page);) {
|
||||
const size_t index = page->live_bytes() >> partition_size_shift;
|
||||
partitions[index]++;
|
||||
@ -90,26 +90,26 @@ void ZRelocationSetSelectorGroup::semi_sort() {
|
||||
}
|
||||
|
||||
// Allocate destination array
|
||||
const int npages = _registered_pages.length();
|
||||
ZArray<ZPage*> sorted_pages(npages, npages, NULL);
|
||||
const int npages = _live_pages.length();
|
||||
ZArray<ZPage*> sorted_live_pages(npages, npages, NULL);
|
||||
|
||||
// Sort pages into partitions
|
||||
ZArrayIterator<ZPage*> iter2(&_registered_pages);
|
||||
ZArrayIterator<ZPage*> iter2(&_live_pages);
|
||||
for (ZPage* page; iter2.next(&page);) {
|
||||
const size_t index = page->live_bytes() >> partition_size_shift;
|
||||
const int finger = partitions[index]++;
|
||||
assert(sorted_pages.at(finger) == NULL, "Invalid finger");
|
||||
sorted_pages.at_put(finger, page);
|
||||
assert(sorted_live_pages.at(finger) == NULL, "Invalid finger");
|
||||
sorted_live_pages.at_put(finger, page);
|
||||
}
|
||||
|
||||
_registered_pages.swap(&sorted_pages);
|
||||
_live_pages.swap(&sorted_live_pages);
|
||||
}
|
||||
|
||||
void ZRelocationSetSelectorGroup::select_inner() {
|
||||
// Calculate the number of pages to relocate by successively including pages in
|
||||
// a candidate relocation set and calculate the maximum space requirement for
|
||||
// their live objects.
|
||||
const int npages = _registered_pages.length();
|
||||
const int npages = _live_pages.length();
|
||||
int selected_from = 0;
|
||||
int selected_to = 0;
|
||||
size_t selected_forwarding_entries = 0;
|
||||
@ -120,7 +120,7 @@ void ZRelocationSetSelectorGroup::select_inner() {
|
||||
|
||||
for (int from = 1; from <= npages; from++) {
|
||||
// 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_forwarding_entries += ZForwarding::nentries(page);
|
||||
|
||||
@ -150,7 +150,7 @@ void ZRelocationSetSelectorGroup::select_inner() {
|
||||
}
|
||||
|
||||
// Finalize selection
|
||||
_registered_pages.trunc_to(selected_from);
|
||||
_live_pages.trunc_to(selected_from);
|
||||
_forwarding_entries = selected_forwarding_entries;
|
||||
|
||||
// Update statistics
|
||||
@ -181,7 +181,7 @@ ZRelocationSetSelector::ZRelocationSetSelector() :
|
||||
_small("Small", ZPageTypeSmall, ZPageSizeSmall, ZObjectSizeLimitSmall),
|
||||
_medium("Medium", ZPageTypeMedium, ZPageSizeMedium, ZObjectSizeLimitMedium),
|
||||
_large("Large", ZPageTypeLarge, 0 /* page_size */, 0 /* object_size_limit */),
|
||||
_garbage_pages() {}
|
||||
_empty_pages() {}
|
||||
|
||||
void ZRelocationSetSelector::select() {
|
||||
// Select pages to relocate. The resulting relocation set will be
|
||||
|
@ -74,7 +74,7 @@ private:
|
||||
const size_t _page_size;
|
||||
const size_t _object_size_limit;
|
||||
const size_t _fragmentation_limit;
|
||||
ZArray<ZPage*> _registered_pages;
|
||||
ZArray<ZPage*> _live_pages;
|
||||
size_t _forwarding_entries;
|
||||
ZRelocationSetSelectorGroupStats _stats;
|
||||
|
||||
@ -90,7 +90,7 @@ public:
|
||||
size_t object_size_limit);
|
||||
|
||||
void register_live_page(ZPage* page);
|
||||
void register_garbage_page(ZPage* page);
|
||||
void register_empty_page(ZPage* page);
|
||||
void select();
|
||||
|
||||
const ZArray<ZPage*>* selected() const;
|
||||
@ -104,7 +104,7 @@ private:
|
||||
ZRelocationSetSelectorGroup _small;
|
||||
ZRelocationSetSelectorGroup _medium;
|
||||
ZRelocationSetSelectorGroup _large;
|
||||
ZArray<ZPage*> _garbage_pages;
|
||||
ZArray<ZPage*> _empty_pages;
|
||||
|
||||
size_t total() const;
|
||||
size_t empty() const;
|
||||
@ -115,11 +115,11 @@ public:
|
||||
ZRelocationSetSelector();
|
||||
|
||||
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;
|
||||
const ZArray<ZPage*>* garbage_pages() const;
|
||||
void clear_garbage_pages();
|
||||
bool should_free_empty_pages(int bulk) const;
|
||||
const ZArray<ZPage*>* empty_pages() const;
|
||||
void clear_empty_pages();
|
||||
|
||||
void select();
|
||||
|
||||
|
@ -75,7 +75,7 @@ inline void ZRelocationSetSelectorGroup::register_live_page(ZPage* page) {
|
||||
const size_t garbage = size - live;
|
||||
|
||||
if (garbage > _fragmentation_limit) {
|
||||
_registered_pages.append(page);
|
||||
_live_pages.append(page);
|
||||
}
|
||||
|
||||
_stats._npages++;
|
||||
@ -84,7 +84,7 @@ inline void ZRelocationSetSelectorGroup::register_live_page(ZPage* page) {
|
||||
_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();
|
||||
|
||||
_stats._npages++;
|
||||
@ -94,7 +94,7 @@ inline void ZRelocationSetSelectorGroup::register_garbage_page(ZPage* page) {
|
||||
}
|
||||
|
||||
inline const ZArray<ZPage*>* ZRelocationSetSelectorGroup::selected() const {
|
||||
return &_registered_pages;
|
||||
return &_live_pages;
|
||||
}
|
||||
|
||||
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();
|
||||
|
||||
if (type == ZPageTypeSmall) {
|
||||
_small.register_garbage_page(page);
|
||||
_small.register_empty_page(page);
|
||||
} else if (type == ZPageTypeMedium) {
|
||||
_medium.register_garbage_page(page);
|
||||
_medium.register_empty_page(page);
|
||||
} 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 {
|
||||
return _garbage_pages.length() >= bulk && _garbage_pages.is_nonempty();
|
||||
inline bool ZRelocationSetSelector::should_free_empty_pages(int bulk) const {
|
||||
return _empty_pages.length() >= bulk && _empty_pages.is_nonempty();
|
||||
}
|
||||
|
||||
inline const ZArray<ZPage*>* ZRelocationSetSelector::garbage_pages() const {
|
||||
return &_garbage_pages;
|
||||
inline const ZArray<ZPage*>* ZRelocationSetSelector::empty_pages() const {
|
||||
return &_empty_pages;
|
||||
}
|
||||
|
||||
inline void ZRelocationSetSelector::clear_garbage_pages() {
|
||||
return _garbage_pages.clear();
|
||||
inline void ZRelocationSetSelector::clear_empty_pages() {
|
||||
return _empty_pages.clear();
|
||||
}
|
||||
|
||||
inline size_t ZRelocationSetSelector::total() const {
|
||||
|
Loading…
Reference in New Issue
Block a user