Sid
Sid

Reputation: 7631

Why is a FileChannel performing better than MemoryMappedBuffer?

I'm reading a 50 gb file (read only) using multiple threads with each thread reading a sequential segment from the file. I tried two approaches

I was expecting the MemoryMappedBuffer to outperform the FileChannel but the FileChannel performs about 30% better consistently.

I'm looking for an explanation. I'm memory mapping in 1 gb at a time and once I run out I map another 1 gb.

My environment: Windows 7 platform 64 bit xeon 2.7 ghz 2 processors

Upvotes: 0

Views: 76

Answers (1)

bmargulies
bmargulies

Reputation: 100051

Both variation have to do the same disk I/O. Both will cache pages in memory as read from disk. Memory mapping has some page-fault overhead. So why do you expect it to be faster, assuming plenty of physical memory to read into?

Upvotes: 2

Related Questions