I have a simple database file with a fixed number of records, each with a fixed length. I don't need to insert or delete anything, I just need to read records. Also, every record is merely dereferenced with an array-like index. All this to say that I don't need to bother with complicated indexing or any 3rd party libraries like SQLite.
Furthermore, every instance of the app will read just 1 record then exit. Many instances could be running at the same time.
I see the following options.
- Don't memory-map anything. Just seek to the target record and read it.
- Memory-map just the record I want.
- Memory-map the whole file.
As I understand it, the biggest reason for memory-mapping files is to dispense with the overhead of system calls. If that's the case then there seems to be little point in going with 2 or 3, since they'll have the same number of system calls as 1 (1 seeks and reads, while 2 and 3 map and unmap). However, since multiple instances will be accessing this file, I'm wondering if there might be an advantage with memory-mapping there.