Skip to content

Conversation

@sbergercnmc
Copy link

Placed HASH_INITIAL_NUM_BUCKETS and HASH_INITIAL_NUM_BUCKETS_LOG2 into a #ifndef block so as to permit these values to be optionally defined in other code before inclusion of uthash.h and thus permit preallocation of hashtable when a lot of keys are expected to be added.

Placed HASH_INITIAL_NUM_BUCKETS and HASH_INITIAL_NUM_BUCKETS_LOG2 into a #ifndef block so as to permit these values to be optionally defined in other code before inclusion of uthash.h and thus permit preallocation of hashtable when a lot of keys are expected to be added.
@Quuxplusone
Copy link
Collaborator

Seems plausible at first glance. Obvious questions:

  • Have you used this in production? Does it help?
  • Surely HASH_BKT_CAPACITY_THRESH should get the same treatment?
  • Needs some test coverage.

@sbergercnmc
Copy link
Author

Doing this for my use case, where I am loading over 300,000,000 keys (uint64_t), my program's loading time goes from 178 seconds to 93 seconds... Agreed that same idea can be applied to HASH_BKT_CAPACITY_THRESH, but I haven't needed this for my use case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants