views:

103

answers:

1

I will be writing a benchmarking tool that will test a mix of IOPS and bandwidth of a disk system and as such I will be turning to file backed memory maps for IO. Because the tool is going to need to be on both POSIX and WinNT platforms I can't just use plain old mmaps. Also from what I understand you have to madvise the Linux kernel that the whole file will be accessed sequentially? Which brings me to Boost memory maps. Are Boost memory maps going to be likely to give me similar performance on similar hardware with similar quality drivers on Windows, Linux and Max OS X? Has anyone benchmarked Boost mmaps across systems?

+2  A: 

Why don't you benchmark and found out? I would suspect that there would be no performance difference, because Boost is merely providing a platform agnostic wrapper facility.

Also, Windows NT platforms provide a memory mapping facility -- it's not like memory mapping is a Linux specific feature. For Windows, you'll want CreateFile, CreateFileMapping and MapViewOfFile. The Windows library differs in that creation of the mapping machinery is separate from creating a mapped view. Otherwise the functionality is equivalent. Oh, just like on POSIX, you need to clean up, in this case with UnmapViewOfFile on the views and CloseHandle on the file mapping and file handle.

Billy ONeal
It's worth asking before committing a lot of work to implement both solutions so you can benchmark. A quick answer on SO that boost is just a thin wrapper is worth a lot
Martin Beckett
To create multiple address mappings of the same file in POSIX, you just call `mmap()` multiple times with the same file descriptor.
caf
@Martin: In general yes, but in this case, we're talking about a maybe 4 function calls versus whatever it takes to get boost's setup working. It's not like implementing both solutions is a seriously complicated thing to do. @caf: I didn't explain myself well... I've rewritten that section.
Billy ONeal
Novikov
@Novikov: No, that is completely different. In this case, it has absolutely nothing to do with experience. We have no way of knowing what load you will put on the system. We have no way of knowing what your benchmarking goals are. Do you want to maximize throughput? Minimize access time? Wwe are talking about an OS facility that requires a **maximum** of 3 calls to try. Given that, I think the only answer is to try it yourself, *under loads you would be using*, and see. No amount of experience helps there. OTOH, experience can be helpful when we are dealing with "documetation-type" questions.
Billy ONeal