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

[FIX] Actually reduce memory usage #192

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions src/hierarchical_interleaved_bloom_filter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ size_t hierarchical_build(hierarchical_interleaved_bloom_filter & hibf,
// initialize lower level IBF
size_t const max_bin_tbs = initialise_max_bin_kmers();
ibf = construct_ibf(parent_kmers, kmers, max_bin_tbs, current_node, data, is_root);
kmers.clear(); // reduce memory peak
kmers = robin_hood::unordered_flat_set<uint64_t>{}; // reduce memory peak

// parse all other children (merged bins) of the current ibf
auto loop_over_children = [&]()
Expand Down Expand Up @@ -123,16 +123,16 @@ size_t hierarchical_build(hierarchical_interleaved_bloom_filter & hibf,
{
auto & child = children[index];

robin_hood::unordered_flat_set<uint64_t> kmers{};
size_t const ibf_pos = hierarchical_build(hibf, kmers, child, data, false);
robin_hood::unordered_flat_set<uint64_t> local_kmers{};
size_t const ibf_pos = hierarchical_build(hibf, local_kmers, child, data, false);
auto parent_bin_index = child.parent_bin_index;
{
size_t const mutex_id{parent_bin_index / 64};
std::lock_guard<std::mutex> guard{local_ibf_mutex[mutex_id]};
technical_bin_to_ibf_id[parent_bin_index] = ibf_pos;
build::insert_into_ibf(kmers, 1, parent_bin_index, ibf, data.fill_ibf_timer);
build::insert_into_ibf(local_kmers, 1, parent_bin_index, ibf, data.fill_ibf_timer);
if (!is_root)
build::update_parent_kmers(parent_kmers, kmers, data.merge_kmers_timer);
build::update_parent_kmers(parent_kmers, local_kmers, data.merge_kmers_timer);
}
}
};
Expand Down