<div dir="ltr">Hi,<div><br></div><div>I hope this is an appropriate list for this question.</div><div><br></div><div>I have been prototyping an FFI-based version of the RocksDB Java API, which is currently implemented in JNI. RocksDB is a C++ based key,value-store with a Java API layered on top. I have done some benchmarking of the FFI implementation, versus the JNI version and I find it performs consistently slightly slower than the current API.</div><div><br></div><div>I would like to understand if this is to be expected, e.g. does FFI do more safety checking under the covers when calling a native method ?</div><div>Or is the performance likely to improve between the preview in Java 19 and release in Java 21 ?</div><div>If there are resources or suggestions that would help me dig into the performance I'd be very grateful to be pointed to them.</div><div><br></div><div>For the use case I'm measuring, data is transferred in native memory originally allocated by RocksDB in C++ which I wrap as a MemorySegment; I do allocate native memory for the request structure.</div><div><br></div><div>These are links to the PR and some documentation of the work:</div><div><br></div><div><a href="https://github.com/facebook/rocksdb/pull/11095">https://github.com/facebook/rocksdb/pull/11095</a><br></div><div><a href="https://github.com/alanpaxton/rocksdb/blob/eb-1680-panama-ffi/java/JavaFFI.md">https://github.com/alanpaxton/rocksdb/blob/eb-1680-panama-ffi/java/JavaFFI.md</a><br></div><div><br></div><div>Many thanks,</div><div>Alan Paxton</div><div><br></div></div>