Skip to content
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

Load balance remembered set scanning #153

Closed
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 13 additions & 7 deletions src/hotspot/share/gc/shenandoah/shenandoahScanRemembered.cpp
Original file line number Diff line number Diff line change
@@ -148,10 +148,13 @@ void ShenandoahScanRememberedTask::do_work(uint worker_id) {


size_t ShenandoahRegionChunkIterator::calc_group_size() {
// First group does roughly half of heap, one region at a time.
// Second group does roughly one quarter of heap, half of a region at a time, and so on.
// Last group does the remnant of heap, one _smallest_chunk_size at a time.
// Round down.
// The group size s calculated from the number of regions. Every group except the last processes the same number of chunks.
// The last group processes however many chunks are required to finish the total scanning effort. The chunk sizes are
// different for each group. The intention is that the first group processes roughly half of the heap, the second processes
// a quarter of the remaining heap, the third processes an eight of what remains and so on. The smallest chunk size
// is represented by _smallest_chunk_size. We do not divide work any smaller than this.
//
// Note that N/2 + N/4 + N/8 + N/16 + ... sums to N if expanded to infinite terms.
return _heap->num_regions() / 2;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand this comment. Is this a TODO comment? Or should this be initial_group_size?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've rewritten the comment here in an attempt to make the intention more clear.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I get it. I think it would be more clear if this method were called initial_group_size as the reduction of subsequent group sizes does not happen in this method.

}

@@ -203,17 +206,20 @@ size_t ShenandoahRegionChunkIterator::calc_total_chunks() {
size_t region_size_words = ShenandoahHeapRegion::region_size_words();
size_t unspanned_heap_size = _heap->num_regions() * region_size_words;
size_t num_chunks = 0;
size_t num_groups = 0;
size_t spanned_groups = 0;
size_t cumulative_group_span = 0;
size_t current_group_span = _first_group_chunk_size * _group_size;
size_t smallest_group_span = _smallest_chunk_size * _group_size;
while (unspanned_heap_size > 0) {
if (current_group_span <= unspanned_heap_size) {
unspanned_heap_size -= current_group_span;
num_chunks += _group_size;
num_groups++;
spanned_groups++;

if (num_groups >= _num_groups) {
// _num_groups is the number of groups required to span the configured heap size. We are not allowed
// to change the number of groups. The last group is responsible for spanning all chunks not spanned
// by previously processed groups.
if (spanned_groups >= _num_groups) {
// The last group has more than _group_size entries.
size_t chunk_span = current_group_span / _group_size;
size_t extra_chunks = unspanned_heap_size / chunk_span;