Clebert Suconic wrote:
> :
> Well.. It is today... but I was hoping it would make it easier for
> developers, as you may find better apis.
> And I also think that a regular developer would have an indirect
> benefit of this. say... if using a higher level API making advantage
> of AIO. (JMS, Mina. or any other layer in top of NIO2).
>> The last time I checked, Linux's kernel AIO was limited to raw devices
> or files opened for direct I/O.
> Yes.. but shouldn't the AsynchronousFileChannel making use of it?
I'll change our implementation to always AIO on Linux if/when it works
for regular files that aren't opened for direct I/O. I prototyped using
this interface a while back but as I recall, and correct me if I'm
wrong, io_submit fails or quietly waits when the file isn't opened for
direct I/O. Performance is always a moving target and we regularly swap
in better implementations so it shouldn't be a problem (replacing the
poll based Selector with the epoll based Selector is a good example). If
we supported the direct I/O option (either in the spec or as an
implementation specific option as the spec allows) then we could use AIO
for file channels opened with that option. As the issues are linked then
the reason we don't always open files for direct I/O is because it
bypasses the file system cache and so any application that doesn't do
its own caching can suffer. That and the usability issue as the
alignment of the file position, buffer alignment and size, need to be
exposed.
> :
> I assumed the newDirectBuffer would call a regular malloc method
> underneath, as I needed an aligned buffer. Maybe my assumption was
> wrong. I will revisit this. (Maybe I should have read the code :-) )
Direct buffers are allocated from the native heap but the alignment
isn't specified. Our implementation has (since 1.4) returned a page
aligned buffer but this is problematic when large pages are used. It
seems to be common now to configure large pages so as to reduce TLS
misses (Sun's CMT processors support 256MB pages so page aligned buffers
can be a killer).
-Alan.