Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The memory used is very high #134

Open
gyd-a opened this issue Jul 12, 2021 · 4 comments
Open

The memory used is very high #134

gyd-a opened this issue Jul 12, 2021 · 4 comments

Comments

@gyd-a
Copy link

gyd-a commented Jul 12, 2021

  1. data type(key: long, value: int)
  2. data size(4200w)
  3. CuckooHash uses 13GB of memory.
  4. std::unordered_map uses 4GB of memory.
    What is the reason? thank you
@manugoyal
Copy link
Contributor

Hi @gyd-a! Do you have a code sample I can run which reproduces the issue?

In general, there are two ways I can think of to reduce the maximum memory usage of the table:

  • Reserve the appropriate table size ahead of time. This improves performance by reducing the number of resize operations, and also reduces max memory usage because the newly resized table doesn't need to keep the memory of the old table around when lazily rehashing.
  • Use a larger SLOT_PER_BUCKET value (the default can be configured in libcuckoo/cuckoohash_config.hh. Roughly speaking, increasing SLOT_PER_BUCKET should improve memory utilization (higher load factor) at the cost of slower hashtable operations.

@gyd-a
Copy link
Author

gyd-a commented Jul 14, 2021

Thank you very much. We changed SLOT_PER_BUCKET from 4 to 8. Memory went from 13GB to 2.2GB. Replay test, unordered_map memory is 1.8g. SLOT_PER_BUCKET =16 is error. error: static assertion failed: pathcode may not be large enough to encode a cuckoo path static_assert(const_pow(slot_per_bucket(), MAX_BFS_PATH_LEN) <

@gyd-a
Copy link
Author

gyd-a commented Jul 14, 2021

As the file is relatively large, you can send your email to my email. I will send the file to your email. [email protected]

@manugoyal
Copy link
Contributor

Glad to hear that helped! Regarding the static_assert error, this is intentional, since we must encode any possible cuckooing path within an integer of size decltype(pathcode). You might be able to bump up the maximum SLOT_PER_BUCKET by changing pathcode from uint16_t to say uint64_t, but I haven't really experimented with this. Again it would be trading performance for memory utilization.

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

No branches or pull requests

2 participants