RFR: 8305092: Improve Thread.sleep(millis, nanos) for sub-millisecond granularity [v5]

Aleksey Shipilev shade at openjdk.org
Wed Apr 19 19:55:42 UTC 2023


On Wed, 19 Apr 2023 18:50:27 GMT, Alan Bateman <alanb at openjdk.org> wrote:

>> Aleksey Shipilev has updated the pull request incrementally with one additional commit since the last revision:
>> 
>>   Windows fixes: align(...) is only for power-of-two alignments
>
> test/jdk/java/lang/Thread/SleepSanity.java line 48:
> 
>> 46: 
>> 47:         for (final int millis : TRY_MILLIS) {
>> 48:             testTimes(() -> Thread.sleep(millis), millis, 10_000);
> 
> I wonder if 10s is enough a tolerance. JDK-8303633 has some sightings of sleep(1000) taking 5.5s. We've since changed all of these to 20s. It might be that 10s is okay, it's just that we seem to run on some test systems (Windows mostly) where we need very high tolerance for tests like this.

Yeah, I was wondering about the same when writing the test. I have not seen it failing yet, and it was pretty slow without the parallelization. To handle the ~5s hiccups, I bumped all "times" tests from 10s to 20s. I kept "timeout" tests at the same 5s timeout, because they normally do wait for those 5s. The accidental hiccup would make timeout test accidentally pass, which I think is a fair trade for keeping the test execution times low.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/13225#discussion_r1171789353


More information about the core-libs-dev mailing list