-
Notifications
You must be signed in to change notification settings - Fork 5.8k
8191565: Last-ditch Full GC should also move humongous objects #12830
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
8191565: Last-ditch Full GC should also move humongous objects #12830
Conversation
👋 Welcome back iwalulya! A progress list of the required criteria for merging this PR into |
Webrevs
|
G1FullGCMarker** _markers; | ||
G1FullGCCompactionPoint** _compaction_points; | ||
OopQueueSet _oop_queue_set; | ||
ObjArrayTaskQueueSet _array_queue_set; | ||
PreservedMarksSet _preserved_marks_set; | ||
G1FullGCCompactionPoint _serial_compaction_point; | ||
G1FullGCCompactionPoint _humongous_compaction_point; | ||
GrowableArray<HeapRegion*>* _humongous_compaction_regions; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This could be a GrowableArrayCHeap<HeapRegion*, mtGC> _humongous_compaction_region
to avoid the necessity for explicit new/delete. Afaics there is no reassignment of that variable ever.
inline void add_humongous_region(HeapRegion* hr) { _humongous_compaction_regions->append(hr); } | ||
GrowableArray<HeapRegion*>* humongous_compaction_regions() { return _humongous_compaction_regions; } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please move to the .inline.hpp
file.
assert(obj->forwardee() != obj, "Object must have a new location"); | ||
|
||
size_t size = obj->size(); | ||
// copy object and reinit its mark |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// copy object and reinit its mark | |
// Copy object and reinit its mark. |
} | ||
} | ||
|
||
void G1FullGCCompactTask::reset_humongous_metadata(HeapRegion* start_hr, uint num_regions, size_t word_size) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe this could somehow be refactored with G1CollectedHeap::humongous_obj_allocate_initialize_regions
; probably not easily.
oop obj = cast_to_oop(src_hr->bottom()); | ||
size_t word_size = obj->size(); | ||
|
||
uint num_regions = (uint) G1CollectedHeap::humongous_obj_size_in_regions(word_size); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
uint num_regions = (uint) G1CollectedHeap::humongous_obj_size_in_regions(word_size); | |
uint num_regions = (uint)G1CollectedHeap::humongous_obj_size_in_regions(word_size); |
// Preserve the mark for the humongous object as the region was initially not compacting. | ||
_collector->marker(0)->preserved_stack()->push_if_necessary(obj, obj->mark()); | ||
|
||
HeapRegion* destn_hr = _compaction_regions->at(range_begin); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would prefer dest_hr
instead of destn_hr
as abbreviation for "destination". It seems unusual.
obj->forward_to(cast_to_oop(destn_hr->bottom())); | ||
assert(obj->is_forwarded(), "Object must be forwarded!"); | ||
|
||
// Add the humongous object regions to the compaction point |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// Add the humongous object regions to the compaction point | |
// Add the humongous object regions to the compaction point. |
} | ||
// Check if the current region and the previous region are contiguous. | ||
bool regions_are_contiguous = (_compaction_regions->at(range_end)->hrm_index() - _compaction_regions->at(range_end - 1)->hrm_index()) == 1; | ||
contiguous_region_count = regions_are_contiguous ? contiguous_region_count + 1 : 1; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
contiguous_region_count = regions_are_contiguous ? contiguous_region_count + 1 : 1; | |
contiguous_region_count = regions_are_contiguous ? contiguous_region_count + 1 : 1; |
|
||
inline void HeapRegion::reset_compacted_humongous_after_full_gc(HeapWord* new_top) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This method could probably just call reset_compacted_after_full_gc
as they are identical. (I am not suggestion to remove this method, although I'm not completely sure it's useful).
} | ||
|
||
// Remove all elements in the range [start - end). The order is preserved. | ||
void erase(int start, int end) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd probably name this new method remove_range
instead of using something completely unrelated.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good.
@walulyai This change now passes all automated pre-integration checks. ℹ️ This project also has non-automated pre-integration requirements. Please see the file CONTRIBUTING.md for details. After integration, the commit message for the final commit will be:
You can use pull request commands such as /summary, /contributor and /issue to adjust it as needed. At the time when this comment was updated there had been 207 new commits pushed to the
As there are no conflicts, your changes will automatically be rebased on top of these commits when integrating. If you prefer to avoid this automatic rebasing, please check the documentation for the /integrate command for further details. ➡️ To integrate this PR with the above commit message to the |
/label add hotspot-gc |
@albertnetymk |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall it looks good, just a couple of small comments below.
Many thanks for taking on this change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good!
Going to push as commit 96889bf.
Your commit was automatically rebased without conflicts. |
Hi All,
Please review this change to move humongous regions during the Last-Ditch full gc ( on
do_maximal_compaction
). This change will enable G1 to avoid encountering Out-Of-Memory errors that may occur due to the fragmentation of memory regions caused by the allocation of large memory blocks.Here's how it works: At the end of
phase2_prepare_compaction
, G1 performs a serial compaction process for regular objects, which results in the heap being divided into two parts. The first part is a densely populated prefix that contains all the regular objects that have been moved. The second part consists of the remaining heap space, which may contain free regions, uncommitted regions, and regions that are not compacting. By moving/compacting the humongous objects in the second part of the heap closer to the dense prefix, G1 reduces the region fragmentation and avoids running into OOM errors.We have enabled for G1 the Jtreg test that was previously used only for Shenandoah to test such workload.
Testing: Tier 1-3
Progress
Issue
Reviewers
Reviewing
Using
git
Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk pull/12830/head:pull/12830
$ git checkout pull/12830
Update a local copy of the PR:
$ git checkout pull/12830
$ git pull https://git.openjdk.org/jdk pull/12830/head
Using Skara CLI tools
Checkout this PR locally:
$ git pr checkout 12830
View PR using the GUI difftool:
$ git pr show -t 12830
Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/12830.diff