1

I want to read/write to a raw device(which is just a file in linux) asyncly, and I have been using java.nio.channels.AsynchronousFileChannel.

But it's a 'fake asynchronous', because the AsynchronousFileChannel uses a thread pool to execute the read/write tasks. It's actually calling the synchronized read/write interface offered by OS.

What I really want is a real asynchronous implementation which is io_submit in linux.

But I can't find it in jdk or any other repositories like guava or apache.

So my question is this :

  1. In java, is there an existing implementation of asynchronous file accessor based on the native io_submit interface ?

  2. If not, why can't I see anyone else who need it ?

T.Tony
  • 495
  • 3
  • 15
  • Wouldn't this go against the very "platform-independent" nature of Java? – rmlan May 02 '18 at 01:49
  • 1
    rmlan, there could be an asynchronous implementation which used io_submit on Linux and threads on platforms which didn't support that mechanism -- it doesn't have to break platform independence. – tgdavies May 02 '18 at 02:20
  • Why do you want to do this? What will this allow you to do that `AsynchronousFileChannel` doesn't? – tgdavies May 02 '18 at 02:21
  • Here's some discussion: http://mail.openjdk.java.net/pipermail/nio-discuss/2011-July/000581.html – tgdavies May 02 '18 at 02:25
  • 1
    @tgdavies, thanks, I saw this discussion. But the reason I want this is that if I turn off the file system cache and the disk buffer, the threads' implementation can't give a good performance comparing to io_submit – T.Tony May 02 '18 at 02:48

1 Answers1

1

In java, is there an existing implementation of asynchronous file accessor based on the native io_submit interface

Not in the default Java libraries at the time of writing (2019). I doubt there's much enthusiasm to implement an io_submit() Java wrapper in the default libraries because:

If not, why can't I see anyone else who need it ?

People who need it that badly have recreated wrappers (e.g. see https://github.com/zrlio/jaio ). However supporting KAIO would be a Linux only thing and thus not that portable (which goes a bit against a key Java ethos).

Anon
  • 6,306
  • 2
  • 38
  • 56