Proposal for adding O_DIRECT support into JDK 9
Lu, Yingqi
yingqi.lu at intel.com
Sat Sep 16 17:20:57 UTC 2017
Hi Brian,
I tested the current DirectIOTest on my Linux CentOS system for 200,000 iterations, they all passed. I tested the same test on MacOS VM for 20 iteration, some of them failed with the "file in cache" error while the rest passed.
I searched online, and found this thread https://lists.apple.com/archives/filesystem-dev/2007/Sep/msg00012.html. If F_NOCACHE flag is set, an IO block might exist in the file system cache for a very short amount of time and then will be evicted.
Then, I tried to add a 200 milliseconds delay between testWrite() and isFileInCache() as well as testRead() and isFileInCache(). I again did 100,000 iterations of DirectIOTest, they all passed. 200,000 iterations take too much time on my VM which is hosted on a tiny desktop :)
I will test DirectIOTest on Solaris VM as well for 100,000 iterations and see how it behaves with and without the delay. My thinking is to add the delay for the platforms who need it.
By the way, I already fixed the DirectIOTest.isDirectIOSupportedByFS() issue on Solaris. I will submit another version of the patch by Monday.
Thanks,
Lucy
From: nio-dev [mailto:nio-dev-bounces at openjdk.java.net] On Behalf Of Lu, Yingqi
Sent: Friday, September 15, 2017 4:02 PM
To: Brian Burkhalter <brian.burkhalter at oracle.com>
Cc: nio-dev at openjdk.java.net
Subject: RE: Proposal for adding O_DIRECT support into JDK 9
Hmm, let me take a look into this MacOS issue. I am wondering if we will need to do "purge" before the testing.
Thanks,
Lucy
From: Brian Burkhalter [mailto:brian.burkhalter at oracle.com]
Sent: Friday, September 15, 2017 3:53 PM
To: Lu, Yingqi <yingqi.lu at intel.com<mailto:yingqi.lu at intel.com>>
Cc: Alan Bateman <Alan.Bateman at oracle.com<mailto:Alan.Bateman at oracle.com>>; nio-dev at openjdk.java.net<mailto:nio-dev at openjdk.java.net>
Subject: Re: Proposal for adding O_DIRECT support into JDK 9
Hi Lucy,
This change works:
--- a/test/java/nio/channels/FileChannel/directio/libDirectIO.c
+++ b/test/java/nio/channels/FileChannel/directio/libDirectIO.c
@@ -71,7 +71,7 @@
const char* path = (*env)->GetStringUTFChars(env, file_path, JNI_FALSE);
- int fd = open(path, 'r');
+ int fd = open(path, 'r', 0600);
(*env)->ReleaseStringUTFChars(env, file_path, path);
All five tests pass in my Ubuntu 16.04 64-bit VM.
On my macOS system I also observed this failure:
java.lang.RuntimeException: DirectIO is not working properly with write. File still exists in cache!
at DirectIOTest.main(DirectIOTest.java:117)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:564)
at com.sun.javatest.regtest.agent.MainActionHelper$SameVMRunnable.run(MainActionHelper.java:230)
at java.base/java.lang.Thread.run(Thread.java:844)
Neither this nor the other failure on macOS occurs every time, i.e., they appear to be intermittent.
Thanks,
Brian
On Sep 15, 2017, at 3:45 PM, Lu, Yingqi <yingqi.lu at intel.com<mailto:yingqi.lu at intel.com>> wrote:
Could you please replace the line 78 in jdk/test/java/nio/channels/FileChannel/directio/libDirectIO.c with the following line and give it a try on your Ubuntu box? I tested it on my CentOS system, it does not complain.
int fd = open(path, 'r', 0600);
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.openjdk.java.net/pipermail/nio-dev/attachments/20170916/c7b5578e/attachment.html>
More information about the nio-dev
mailing list