RFR: JDK-8028628 - java/nio/channels/FileChannel/Size.java failed once in the same binary run
Dan Xu
dan.xu at oracle.com
Thu Nov 21 12:42:51 PST 2013
Hi Alan,
When looking at the FileChannel.map() method, it seems that it will not
write "e" 4 billion times. Instead, it only extends the file size to
testSize+10. It uses ftruncate() in linux and uses SetFilePointer() in
Windows, which causes the file offset different on different platforms.
But the performance should be good. On windows, this test runs for
around 0.14 seconds in jprt machines. Thanks!
-Dan
On Thu 21 Nov 2013 11:51:28 AM PST, Alan Bateman wrote:
> On 21/11/2013 17:02, Dan Xu wrote:
>>
>> Hi Alan,
>>
>> I think the map is used to enlarge the size of the largeFile to
>> testSize + 10. In initTestFile(), it initiates the file with size 10.
>> My understanding is that it avoids writing large amount of data into
>> the largeFile by using the map. Thanks!
>>
>> -Dan
> Okay, I guess I was really just wondering about the reliability on
> Windows as sometimes tests that use memory mapped files are
> troublesome when it comes to clean-up after the test. Also as this
> test hasn't run on Windows before then I wonder about how long
> initTestFile will take to create the 4GB file. You've probably
> measured already but if you need a speed up then you could change
> initTestFile to use a FIleChannel and create the file with the SPARSE
> option. Then just position to size-1 and write 1 byte. That should be
> faster than writing "e" 4 billion times.
>
> -Alan.
>
More information about the nio-dev
mailing list