On Tue, 8 Oct 2024 17:10:43 GMT, Ramkumar Sunderbabu <[email protected]> 
wrote:

> The time difference check might fail for scenarios such as batch compilation. 
> It is safer to give a bigger allowance of 10 seconds instead of 0.1 sec.
> 
> Testing: The test was run for 100 times with -Xcomp option.

Background of the issue:


        Instant expected = Instant.now(Clock.systemUTC());
        Instant test = Instant.now();
        long diff = Math.abs(test.toEpochMilli() - expected.toEpochMilli());
        assertTrue(diff < 100);  // less than 0.1 secs


In normal cases, the difference between the test and expected stay within the 
threshold of 100ms.
Issue happens when the code is run with compilation options such as -Xcomp, 
-Xbatch etc. The aggressive JIT optimizations and other stop-the-world pauses 
introduce delay in execution and the difference ends up more than 100ms.
The difference is increased to 10s to account for such delays.

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

PR Comment: https://git.openjdk.org/jdk/pull/21413#issuecomment-2404108128

Reply via email to