RFR: 8294437: java/nio/channels/FileChannel tests slow on Windows

Alan Bateman alanb at openjdk.org
Wed Sep 28 19:07:23 UTC 2022


On Wed, 28 Sep 2022 10:58:43 GMT, Daniel Jeliński <djelinski at openjdk.org> wrote:

> Please review this test-only change that improves the execution speed of a few FileChannel tests:
> - Transfer2GPlus, Transfer4GBFile, and TransferTo6GBFile were modified to use sparse files. Their speed is now consistent across platforms, provided that the platform / filesystem supports sparse files.
> - LargeMapTest was rewritten to use sparse files, and to more precisely target the issue it was written to detect. In my tests it still crashed with EXCEPTION_ACCESS_VIOLATION when JDK-8286637 was reverted.
> - MapTest: repetition was removed from `testForce` method; I'm not sure what issues it was supposed to catch, but at far as I can tell, it was only triggering timeouts, see [JDK-8289526](https://bugs.openjdk.org/browse/JDK-8289526), [JDK-8224480](https://bugs.openjdk.org/browse/JDK-8224480)

Creating the files as sparse files make sense, we probably should have changed these tests a long time ago.

test/jdk/java/nio/channels/FileChannel/LargeMapTest.java line 64:

> 62:         try (FileChannel fc = FileChannel.open(p, CREATE_NEW, SPARSE, WRITE)) {
> 63:             fc.position(BASE);
> 64:             Random r = new Random(System.nanoTime());

It might not matter here but we usually use RandomFactory to allow for reproducibility in the event of test failure.

test/jdk/java/nio/channels/FileChannel/MapTest.java line 95:

> 93:             t1 = System.nanoTime();
> 94:             out.printf("Exceptions: done in %d ns (%d ms) %n",
> 95:                     t1 - t0, TimeUnit.NANOSECONDS.toMillis(t1 - t0));

Are you planning to leave all these timestamps in the output? I can't tell if they are left over from your testing or intentional.

test/jdk/java/nio/channels/FileChannel/Transfer2GPlus.java line 81:

> 79:         throws IOException {
> 80:         try (FileChannel fc = FileChannel.open(src, StandardOpenOption.CREATE_NEW,
> 81:                 StandardOpenOption.SPARSE, StandardOpenOption.WRITE)) {

LargeMapFile uses import static java.nio.file.StandardOpenOption.* which makes it easier to fit the open options on the same line.

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

PR: https://git.openjdk.org/jdk/pull/10464


More information about the nio-dev mailing list