LevelDB vs. std::map

后端 未结 2 2091
执笔经年
执笔经年 2021-02-04 17:18

In our application we use std::map to store (key, value) data and use serialization to store that data on disk. With this approach we are finding that the disk I/O

2条回答
  •  [愿得一人]
    2021-02-04 17:37

    LevelDB just does something else than std::map.

    Are you really saying you want (high performance) persistence for std::map?

    • look at std::map with a custom allocator. Allocate the entries from a memory mapped region and use fsync to to ensure the information hits the disk at strategic moments in time.

      • mmap
      • boost iostreams memory mapped files
    • perhaps combine that with EASTL (which boasts a faster std::map and thrives with custom allocators - in fact they have no default allocator)

      • EASTL
    • look at tuning your hash_map (std::unorderded_map); if hash_maps are slower, you should look into (a) loadfactor (b) hash function tuning

      • docs
    • last but not least: evaluate the use of Boost Serialization for binary serialization of your map (whatever implementation you picked). In my experience Boost Serialization performance is top of the bill.

      • Boost serialization

提交回复
热议问题