I've spent some more time playing with memory-mapped BLOBs with very satisfactory results. Not only It's a great win in terms of performance, but it also helps one to appreciate pure data rather than various code-driven dynamic data structures and other complicated abstractions. This change in mindset seems to be crucial in these days of highly concurrent systems. Moreover, carefully designed data will surely outlive all that fragile code around. A nice pack of data is also easier to visualize and reason about. So to me, it seems like a pretty good long-term investment too.

As I'm just implementing an asynchronous read-only file system or file cache, which I call just Bundle, I've come up with a BLOB to represent its directory structure. Using a Python script similar to the one in my previous post I get a BLOB like this:

So as you can see, with this approach a pretty complicated data structure can be fetched in one run, using just a single memory allocation. We can completely get rid of allocation-hungry STLcontainers, but still preserve the ability to use STL algorithms (on condition that custom iterators are provided, which is not that difficult). A carefully 64-bit aligned BLOB is perfectly suited for both 32 and 64-bit code running over it. Data can be easily arranged into Structure of Arrays (SOA) to separate hot and cold pieces in order to provide better cache locality. All this offers high-performance concurrent access, especially when dealing with read-only data.