RFR: Elastic TLABs may avoid racily peeking into the free set
Roman Kennke
rkennke at redhat.com
Tue Jul 17 15:42:29 UTC 2018
Good, go!
Roman
> CollectedHeap::unsafe_max_tlab_alloc is used to determine the momentary max tlab size, peeking
> racily into GC state (thus "unsafe_"). This is needed to avoid retiring regions that would not fit
> the max tlab if there is not enough space available in current allocation region. Because it is
> racy, it can grossly miscalculate under heavy allocations, when other threads are actively mutating
> the current allocation region. Fortunately, with Elastic TLABs, this peeking is not needed, as
> allocation path would figure it out itself.
>
> diff -r e2c2bf800963 src/hotspot/share/gc/shenandoah/shenandoahHeap.cpp
> --- a/src/hotspot/share/gc/shenandoah/shenandoahHeap.cpp Tue Jul 17 16:54:17 2018 +0200
> +++ b/src/hotspot/share/gc/shenandoah/shenandoahHeap.cpp Tue Jul 17 17:29:56 2018 +0200
> @@ -1370,13 +1370,19 @@
>
> bool ShenandoahHeap::supports_tlab_allocation() const {
> return true;
> }
>
> -size_t ShenandoahHeap::unsafe_max_tlab_alloc(Thread *thread) const {
> - // Returns size in bytes
> - return MIN2(_free_set->unsafe_peek_free(), ShenandoahHeapRegion::max_tlab_size_bytes());
> +// Returns size in bytes
> +size_t ShenandoahHeap::unsafe_max_tlab_alloc(Thread *thread) const {
> + if (ShenandoahElasticTLAB) {
> + // With Elastic TLABs, return the max allowed size, and let the allocation path
> + // figure out the safe size for current allocation.
> + return ShenandoahHeapRegion::max_tlab_size_bytes();
> + } else {
> + return MIN2(_free_set->unsafe_peek_free(), ShenandoahHeapRegion::max_tlab_size_bytes());
> + }
> }
>
> size_t ShenandoahHeap::max_tlab_size() const {
> // Returns size in words
> return ShenandoahHeapRegion::max_tlab_size_words();
>
> Testing: ad-hoc benchmarks, tier1_gc_shenandoah, tier3_gc_shenandoah (running)
>
> Thanks,
> -Aleksey
>
More information about the shenandoah-dev
mailing list