I'm new to the list, so forgive me if this has been gone over before.
I've written a program that needs to read/write lots of cache files to
disk. They are around 100k a piece though it can vary quite a bit.
In response to user action I need to load 2-5 of these cache files and
update the GUI. On windows and linux the read times for these cache
images average around 250ms. However on OS X the mean time to load
rises to 450ms with some exceeding 1200ms.
[snip]
I pointed this little test class at a directory filled with 1 - 1.5Meg
jpegs. About 95 of them. Here's what I wound up with:
Min: 25ms (Faster then any other platform)
Max: 8935ms (Slower by a factor of 5 then any other platform)
Mean: 2030ms (Slower by half then any other platform)
i don't have much experience of MS Windows, but compared to Linux,
Mac OS' file I/O blows goats. it doesn't seem to be Java's fault:
it's the OS itself.
one thing that's particularly crippling is Mac OS' apparent lack of
interest in caching data (meta and user, from what i remember, but
definitely user). Linux really goes all-out to cache as much as it
can for as long as it can, and it really pays off on successive
reads. Mac OS doesn't get much faster, no matter how many times you
read something.
you can observe this with grep(1) or whatever. grep the GCC source
tree, say, on Linux and Mac OS machines with lots of memory. gasp in
awe at the Linux machine's second run, and maybe throw a party for it
to give the Mac chance to catch up.
Cyrill Rüttimann wrote:
If you target JDK 1.4 or above, consider using NIO for reading files.
It should be considerable faster for your purposes.
but not necessarily, and in my experience it's unlikely to be
competitive with the same code on other platforms. especially Linux.
there are big savings to be made if you're reading characters, but
for bytes i've had less success. i'm not sure this guy's files are
large enough to take advantage of mmap, for example. (see the note in
the JavaDoc http://java.sun.com/j2se/1.5.0/docs/api/java/nio/channels/
FileChannel.html#map(java.nio.channels.FileChannel.MapMode,%20long,%
20long) which certainly seems to correspond to my experience).
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Java-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/java-dev/email@hidden