Skip to content

Commit 4c79e7d

Browse files
author
Ivan Walulya
committed
8170817: G1: Returning MinTLABSize from unsafe_max_tlab_alloc causes TLAB flapping
Reviewed-by: tschatzl, ayang
1 parent 7633a76 commit 4c79e7d

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/hotspot/share/gc/g1/g1Allocator.cpp

+6-3
Original file line numberDiff line numberDiff line change
@@ -191,11 +191,14 @@ size_t G1Allocator::unsafe_max_tlab_alloc() {
191191
uint node_index = current_node_index();
192192
HeapRegion* hr = mutator_alloc_region(node_index)->get();
193193
size_t max_tlab = _g1h->max_tlab_size() * wordSize;
194-
if (hr == nullptr) {
194+
195+
if (hr == nullptr || hr->free() < MinTLABSize) {
196+
// The next TLAB allocation will most probably happen in a new region,
197+
// therefore we can attempt to allocate the maximum allowed TLAB size.
195198
return max_tlab;
196-
} else {
197-
return clamp(hr->free(), MinTLABSize, max_tlab);
198199
}
200+
201+
return MIN2(hr->free(), max_tlab);
199202
}
200203

201204
size_t G1Allocator::used_in_alloc_regions() {

0 commit comments

Comments
 (0)