Skip to content

cuckoohashmap taking high memory  #136

@naidud2020

Description

@naidud2020

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.

nested_table.cc.txt

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;
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions