8372861: Genshen: Override parallel_region_stride of ShenandoahResetBitmapClosure to a reasonable value for better parallelism

Reviewed-by: kdnilsen, shade, wkemper
This commit is contained in:
Xiaolong Peng 2025-12-03 22:43:17 +00:00
parent 1294d55b19
commit db2a5420a2
4 changed files with 13 additions and 1 deletions

View File

@ -76,6 +76,9 @@ public:
}
}
// Bitmap reset task is heavy-weight and benefits from much smaller tasks than the default.
size_t parallel_region_stride() override { return 8; }
bool is_thread_safe() override { return true; }
};

View File

@ -1962,7 +1962,7 @@ void ShenandoahHeap::parallel_heap_region_iterate(ShenandoahHeapRegionClosure* b
assert(blk->is_thread_safe(), "Only thread-safe closures here");
const uint active_workers = workers()->active_workers();
const size_t n_regions = num_regions();
size_t stride = ShenandoahParallelRegionStride;
size_t stride = blk->parallel_region_stride();
if (stride == 0 && active_workers > 1) {
// Automatically derive the stride to balance the work between threads
// evenly. Do not try to split work if below the reasonable threshold.

View File

@ -113,6 +113,7 @@ public:
class ShenandoahHeapRegionClosure : public StackObj {
public:
virtual void heap_region_do(ShenandoahHeapRegion* r) = 0;
virtual size_t parallel_region_stride() { return ShenandoahParallelRegionStride; }
virtual bool is_thread_safe() { return false; }
};

View File

@ -44,6 +44,10 @@ public:
}
}
size_t parallel_region_stride() override {
return _closure->parallel_region_stride();
}
bool is_thread_safe() override {
return _closure->is_thread_safe();
}
@ -64,6 +68,10 @@ public:
}
}
size_t parallel_region_stride() override {
return _closure->parallel_region_stride();
}
bool is_thread_safe() override {
return _closure->is_thread_safe();
}