EtiennePerot / fuse-jna

No-nonsense, actually-working Java bindings to FUSE using JNA.
http://fusejna.net/
Other
137 stars 43 forks source link

Performance: Direct mapped library and callbacks #33

Open tass01024 opened 10 years ago

tass01024 commented 10 years ago

Thanks for the good work!

Would it not be a performance boost to use directly mapped library (LibFuse) and FileSystem callbacks (Options: Native.CB_OPTION_DIRECT) to boost performance of the calls?

By using JNA's: Native.register instead of loadLibrary and using the Native.CB_OPTION_DIRECT

It would ofcause require some refactoring of the code.

/rasmus

EtiennePerot commented 10 years ago

I'm not entirely clear on what this would achieve besides shorter stacks, which I don't really think are a bottleneck. Feel free to try it though.

rossjudson commented 10 years ago

You mention that allocating direct byte buffers is a significant bottleneck, and those are known to be slow.

It's possible that can be mitigated by changing

  final ByteBuffer buf = buffer.getByteBuffer(0, bufSize);
  final FileInfoWrapper wrapper = new FileInfoWrapper(path, info);
  final int result = read(path, buf, bufSize, readOffset, wrapper);

into something more like

  final byte [] buf = buffer.getByteArray(0, bufSize);
  final FileInfoWrapper wrapper = new FileInfoWrapper(path, info);
  final int result = read(path, buf, bufSize, readOffset, wrapper);
  buffer.write(0, buf, 0, bufSize);

The JVM is pretty efficient with transient byte arrays, so it might not make sense to pools those.