Search code examples
c++boostinterprocess

interprocess map versus map/unordered_map


There are a lot of discussions about the differences between std::map and boost::unordered_map. But what about boost::interprocess::map ?

Did somebody perform perfomance tests between boost::interprocess::map and std::map ?

I haven't used interprocess::map so much but i have the feeling that above 1M elements, it becomes really slow.

Thanks


Solution

  • Boost interprocess containers are standard containers with custom allocators.

    Reason: when two processes share memory, the memory is mapped to different addresses in the two processes. To be able to use pointers to shared memory objects, one must not use absolute addresses but relative offsets (which are identical in both processes).

    So the allocator classes relevant to boost::interprocess involve extra arithmetic at dereferenciation. They define a custom pointer type which is slightly heavier to use than normal pointers.

    Apart from that, the containers are exactly the same as the standard ones. Same complexity, and only a slight overhead at element access (an extra addition). The differences between map and unordered_map for instance will be reflected as is in when using the special interprocess allocator.