-
Notifications
You must be signed in to change notification settings - Fork 281
Description
Tried with cuckoohashmap and unordered_map.
for same data, cuckoohashmap taken morethan 64GB on RAM and crashed. unordered_map finished with 1.5GB on RAM.
I would like to give preference to libcuckoo hash map(concurrent). Attaching sample c++ code. Do let me know whether libcuckoo supports with such a small memory footprint like unordered_map.
code:
/* We demonstrate how to nest hash tables within one another, to store
- unstructured data, kind of like JSON. There's still the limitation that it's
- statically typed. */
#include
#include
#include
#include
#include <unordered_map>
#include <libcuckoo/cuckoohash_map.hh>
void test_with_cuckuoo_hash()
{
typedef libcuckoo::cuckoohash_map<std::string, std::string> InnerTable;
typedef libcuckoo::cuckoohash_map<std::string, std::unique_ptr> OuterTable;
OuterTable tbl;
tbl.reserve(5000000); //reserved
for(int i = 1000000; i < 6000000; ++ i) {
std::string outer_key{std::to_string(i)};
std::string inner_key{std::to_string(i)};
std::string inner_val{std::to_string(i)};
tbl.insert(outer_key, std::unique_ptr<InnerTable>(new InnerTable));
tbl.update_fn(outer_key, [&](std::unique_ptr<InnerTable> &innerTbl) {
innerTbl->reserve(4); //reserved
innerTbl->insert(inner_key, inner_val);
});
}
std::cout << "count: " << tbl.size() << std::endl;
}
void test_with_unordered_map()
{
typedef std::unordered_map<std::string, std::string> InnerTable;
typedef std::unordered_map<std::string, std::unique_ptr> OuterTable;
OuterTable tbl;
for(int i = 1000000; i < 6000000; ++ i) {
std::string outer_key{std::to_string(i)};
std::string inner_key{std::to_string(i)};
std::string inner_val{std::to_string(i)};
std::unique_ptr<InnerTable> inner_tbl = std::make_unique<InnerTable>();
inner_tbl->insert({inner_key, inner_val});
tbl.insert({outer_key, std::move(inner_tbl)});
}
std::cout << "count: " << tbl.size() << std::endl;
}
int main() {
//test_with_cuckuoo_hash(); //CONSUMING MORE THAN 64 GB, STILL COULDNT COMPLETE
test_with_unordered_map(); //CONSUMING 1.5 GB
return 0;
}