r/java • • Jun 10 '24

[deleted by user]

[removed]

616 Upvotes

594 comments sorted by

View all comments

Show parent comment

3

u/ai_jarvis Jun 11 '24

We didn't do an FFI, just the NIO API and the file took ~19 seconds to map whereas the same file was done in less than 2 seconds with GO.

Java used 2.1x file size of memory vs GO which was just 4% larger than the file.

Look up times were faster too.

3

u/koflerdavid Jun 12 '24

This sounds like there are lots of optimization opportunities in that API. Although part of the problem might be that any data has to be copied to the heap to be accessible for Java code. ByteBuffers can provide limited access to off-heap memory, but retrieving data through these is equivalent to copying data around.