Hashmap efficiency for stdxt C ++ - reorganization (?)

I came across a rather strange thing related to the stdext hashmap. I have to work with a large number of objects, and quick access to elements is a priority for them. My program reads the values ​​of the object from the file and, if it is a new element, then paste this value into the hash map, if it is an already processed object, then changes the stored value in hashmap.

My problem is with hashmap(stdext). I did not find any initialization option for this container.

The key element is an unsigned integer ( uint64), and this object is stored in a hash map with this key with a size of 160 Kbytes.
The program works, but I have to wait too much when the number of objects in hashmap reaches the limit.

After that, hashmap works fine again, as I expect. I thought maybe this is a step of reorganization.

But these steps are crucial, because after a certain number of objects for this step, it takes 5 hours, while the usual processing step is about 2-3 minutes. After that, the processing becomes "normal".

Has anyone encountered such problems? Does anyone know something deeper in this hashmap? I did not find anything relevant related to this topic.


I am trying to use hashmap options with non-standard values: bucket_sizeand min_buckets. The default values ​​for this are: bucket_size=4and min_buckets=8. I changed them in the xhash file to larger values ​​because I was unable to change these values ​​from the code. I think that min_bucketsis crucial in my application, I try to “finance” in order to get better performance, avoiding the reorganization step.

But I have a different problem, everything works fine until I try to clear the hash map. It takes a lot of time. When I use it with default values, it is very fast.

Was this a bad step to modify the xhash file? Has anyone used non-default values ​​before? What are the reasons for this slow clarity?

hashmap. , . ; hashmap, , . ? , , .

.

+3
4

, , ( ). boost:: shared_ptr, .

, , , , , .

+3

, , . :

  • , void resize(size_type n).

  • , .

0

( ) -.

( ). , , , , . resize(). ,

  • ( AFAIK)
  • Choose the best hashing algorithm

You can, if you want, check with your hashmap implementation to make sure that they follow the idiom movement. If they do not give him a shot.

0
source

Use Java. You will be shocked by the manner in which it will beat C ++ when it comes to efficient investments in the hash map (the best allocators, without copying) and compares them with searches.

0
source

Source: https://habr.com/ru/post/1703770/


All Articles