Integrated: 8268906: gc/g1/mixedgc/TestOldGenCollectionUsage.java assumes that GCs take 1ms minimum

Thomas Schatzl tschatzl at openjdk.java.net
Wed Jun 30 09:17:06 UTC 2021


On Fri, 18 Jun 2021 17:43:05 GMT, Thomas Schatzl <tschatzl at openjdk.org> wrote:

> Hi,
> 
>   can I have reviews for this change to a test that incorrectly assumed that GCs take 1ms minimum?
> 
> At the end of the test, MXBeans' `getCollectionTime()` is compared against one taken two gcs earlier. If these two gcs are very short, `getCollectionTime()` returns the same value as before because its resolution is 1ms.
> 
> The `getCollectionTime()` documentation states:
> 
>> Returns the approximate accumulated collection elapsed time in milliseconds. This method returns -1 if the collection elapsed time is undefined for this collector.
>> 
>> The Java virtual machine implementation may use a high resolution timer to measure the elapsed time. **This method may return the same value even if the collection count has been incremented if the collection elapsed time is very short.**
>> 
> 
> Which is what the test tested
> 
> Testing: test does not fail any more after some VM hack so that `getCollectionTime()` returns very low values.
> 
> Thanks,
>   Thomas

This pull request has now been integrated.

Changeset: a0f32cb1
Author:    Thomas Schatzl <tschatzl at openjdk.org>
URL:       https://git.openjdk.java.net/jdk/commit/a0f32cb1406e4957e84befd9b68444adb662bd13
Stats:     2 lines in 1 file changed: 0 ins; 0 del; 2 mod

8268906: gc/g1/mixedgc/TestOldGenCollectionUsage.java assumes that GCs take 1ms minimum

Reviewed-by: kbarrett, ayang, lkorinth

-------------

PR: https://git.openjdk.java.net/jdk/pull/4531


More information about the hotspot-gc-dev mailing list