C++ map insertion and lookup performance and storage overhead

前端 未结 8 2037
旧巷少年郎
旧巷少年郎 2021-02-02 10:47

I would like to store a mapping of an integer key to a float value in-memory.

I have roughly 130 million keys (and, accordingly, 130 million v

8条回答
  •  日久生厌
    2021-02-02 11:52

    Considering the vast amount of memory used, you must also consider that any memory access in searching will result in a memory cache fault.

    In this regard a mixed solution of a small hashmap as first layer and sorted vectors for the buckets is probably the best.

    The idea is to keep the hashtable index in the cache memory, and to search in smaller sorted containers to reduce the number of cache faults.

提交回复
热议问题