loyalflow
loyalflow

Reputation: 14919

When performing mmap, would C or Java have any significant performance differences?

I have a 50GB file that is a sorted csv file.

Would it in theory make any difference if I was performing lookups on this file using memory mapped access using C or java?

I'm guessing since the file access is pushed down to the operating system level, it really shouldn't make much of a difference correct?

Upvotes: 1

Views: 510

Answers (3)

cmccabe
cmccabe

Reputation: 4340

Java can only map 2 GB at a time. This is because ByteBuffer uses 32-bit integers for length, size, etc. So you'd need 25 mmaps for your 50 GB file. C can just create a single mmap, although it won't be portable to 1990s computers (if you care about that)

Upvotes: 1

Erik Kaju
Erik Kaju

Reputation: 3173

Giving a direct answer to question.

C's mmap() and Java's FileChannel.map() are considered to be pretty much equivalents and won't have significant performance differences.

Upvotes: 1

parsifal
parsifal

Reputation: 1266

In theory, Java will be infinitesimally slower because of the need for additional indirections due to Java's object-oriented method invocation, and possibly due to the need to cross the Java/JNI boundary.

In practice, the Hotspot compiler optimizes direct ByteBuffer access, and the cost of page faults will far exceed the extra memory indirection.

Upvotes: 2

Related Questions