My employer has asked me to prepare a presentation on NIO based on my previous experience with the apis. My experience is limited to using buffers to pass data to native code and exposing chunks of native memory via direct bytebuffers. I’ve been experimenting with other bits of the apis, trying to find some noticeable performance benefits in the context of file processing. Unfortunately I haven’t been able to find any so far. I was hoping someone could answer the following questions so I can get a better understanding of what types of performance improvements I should expect.
Has anyone noticed great performance improvements going from stream based io to channel based io? By this I don’t mean blocking, one thread per stream versus non-blocking multiplexed. Just InputStream versus Channel.
Does read(ByteBuffer) have any immediate benefits compared to read(byte[])? Related to that question is writing to a direct bytebuffer from native code always much faster than writing to an array using getPrimitiveArrayCritical?
I read on some guys blog that getPrimitiveArrayCritical basically halts all running threads. Was this actually and is this still the case in hotspot?
Any idea on how I could improve on this idea to make the results clearer to my audience? The current version performs disk I/O and my hunch is that this doesn’t push data through the CPU fast enough to notice a big difference. I’m planning on changing the test to write out to a socket. Maybe that will work better.