Proposal for adding O_DIRECT support into JDK 9

Lu, Yingqi yingqi.lu at intel.com
Sat Nov 5 18:33:12 UTC 2016


Hi Alan and David,

Thank you for your email.

I totally agree that OS kernel supports multiple page sizes. For example, my Linux box supports both 4K and 2M pages. Currently, our getAlignment() function inside FileChannel/FileChannelImpl calls an existing function sun.nio.ch.Util.pageSize() which eventually calls unsafe.pageSize(). I use a small Java program to test unsafe.pageSize() with and without the flag " -XX:+UseLargePages" on my Linux box, both testing return 4096. 
 
To make DirectIO work, IO size and file position need to be aligned to the disk block size. Native memory page size (in our case, 4096) is always a multiple or equal of disk block size. That is why we try to use this existing JDK function (sun.nio.ch.Util.pageSize()) for the alignment value. To make it simpler, we use getAlignment as the function name and put it inside the FileChannel/FileChannelImpl.

Please let us know if you have any questions, comments and concerns. Thank you very much for your consideration!

Thanks,
Lucy

>-----Original Message-----
>From: Alan Burlison [mailto:Alan.Burlison at oracle.com]
>Sent: Saturday, November 05, 2016 1:13 AM
>To: David M. Lloyd <david.lloyd at redhat.com>; Paul Sandoz
><paul.sandoz at oracle.com>; Lu, Yingqi <yingqi.lu at intel.com>
>Cc: nio-dev at openjdk.java.net; Kaczmarek, Eric <eric.kaczmarek at intel.com>;
>core-libs-dev at openjdk.java.net; Kharbas, Kishor <kishor.kharbas at intel.com>
>Subject: Re: Proposal for adding O_DIRECT support into JDK 9
>
>On 04/11/2016 18:32, David M. Lloyd wrote:
>
>> I still feel like it could be a problem to have just one simple
>> getPageSize method, given how many CPU architectures and OSes support
>> multiple page sizes.
>
>Yes.
>
>$ pagesize -a
>8192
>65536
>4194304
>268435456
>2147483648
>
>--
>Alan Burlison
>--


More information about the core-libs-dev mailing list