RFR: GCLAB slowpath allocations should fit the object into GCLAB

Aleksey Shipilev shade at redhat.com
Mon Jul 16 11:22:36 UTC 2018


Was backporting this code, and realized that we have a bad bug: we can get GCLAB smaller than
allocation that should fit in it! Oops. The bug seems preexisting -- e.g. GCLAB stats might have
replied smaller size too -- but elastic GCLABs make it more probable.

Fixed with:

diff -r e6c9cf5a0a73 src/hotspot/share/gc/shenandoah/shenandoahHeap.cpp
--- a/src/hotspot/share/gc/shenandoah/shenandoahHeap.cpp        Fri Jul 13 21:14:44 2018 +0200
+++ b/src/hotspot/share/gc/shenandoah/shenandoahHeap.cpp        Mon Jul 16 13:01:57 2018 +0200
@@ -754,17 +754,22 @@
     new_gclab_size = _mutator_gclab_stats->desired_plab_sz(Threads::number_of_threads());
   } else {
     new_gclab_size = _collector_gclab_stats->desired_plab_sz(workers()->active_workers());
   }

+  // Allocated object should fit in new GCLAB, and new_gclab_size should be larger than min
+  size_t min_size = MAX2(size, PLAB::min_size());
+  new_gclab_size = MAX2(new_gclab_size, min_size);

   // Allocate a new GCLAB...
   size_t actual_size = 0;
-  HeapWord* gclab_buf = allocate_new_gclab(PLAB::min_size(), new_gclab_size, &actual_size);
+  HeapWord* gclab_buf = allocate_new_gclab(min_size, new_gclab_size, &actual_size);
   if (gclab_buf == NULL) {
     return NULL;
   }

+  assert (size <= actual_size, "allocation should fit");
+
   if (ZeroTLAB) {
     // ..and clear it.
     Copy::zero_to_words(gclab_buf, actual_size);
   } else {
     // ...and zap just allocated object.


Testing: tier3_gc_shenandoah (in sh/jdk8; sh/jdk is in progress)

Thanks,
-Aleksey



More information about the shenandoah-dev mailing list