RFR: Underflow in adaptive free_threshold calculation
Roman Kennke
rkennke at redhat.com
Fri Aug 4 10:38:30 UTC 2017
Am 04.08.2017 um 10:53 schrieb Aleksey Shipilev:
> Happens when free threshold is already small, and "step" moves it over the zero to negative value.
> But, because we calculate with unsigned math, it underflows. This is not catastrophic, because we
> would cap at ShenandoahMaxFreeThreshold, but it is a performance bug nevertheless.
>
> Fix:
>
> $ hg diff
> diff -r 01ce666f15f1 src/share/vm/gc/shenandoah/shenandoahCollectorPolicy.cpp
> --- a/src/share/vm/gc/shenandoah/shenandoahCollectorPolicy.cpp Thu Aug 03 17:21:19 2017 +0200
> +++ b/src/share/vm/gc/shenandoah/shenandoahCollectorPolicy.cpp Fri Aug 04 10:50:35 2017 +0200
> @@ -676,7 +676,8 @@
> }
>
> void adjust_free_threshold(intx adj) {
> - uintx new_threshold = _free_threshold + adj;
> + intx new_value = adj + _free_threshold;
> + uintx new_threshold = (uintx)MAX2<intx>(new_value, 0);
> new_threshold = MAX2(new_threshold, ShenandoahMinFreeThreshold);
> new_threshold = MIN2(new_threshold, ShenandoahMaxFreeThreshold);
> if (new_threshold != _free_threshold) {
>
> Testing: some performance tests, hotspot_gc_shenandoah
>
> Thanks,
> -Aleksey
>
Looks good
More information about the shenandoah-dev
mailing list