Skip to content

Commit

Permalink
Merge pull request #196 from vgteam/less-parallel-overlays
Browse files Browse the repository at this point in the history
Make overlay construction less parallel and lookup hopefully faster
  • Loading branch information
adamnovak authored Jul 9, 2024
2 parents 6c668b7 + cd99393 commit b5d6fdd
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class PackedPositionOverlay : public PathPositionHandleGraph, public ExpandingOv
/// Make a new PackedPositionOverlay, on the given graph. Glom short paths
/// together to make internal indexes each over at least the given number
/// of steps.
PackedPositionOverlay(const PathHandleGraph* graph, size_t steps_per_index = 1000000);
PackedPositionOverlay(const PathHandleGraph* graph, size_t steps_per_index = 20000000);
PackedPositionOverlay() = default;
PackedPositionOverlay(const PackedPositionOverlay& other) = default;
PackedPositionOverlay(PackedPositionOverlay&& other) = default;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class PackedReferencePathOverlay : public PackedPositionOverlay {

/// Make a PackedReferencePathOverlay. Do the indexing and compute the
/// additional indexes that the base class doesn't have.
PackedReferencePathOverlay(const PathHandleGraph* graph, size_t steps_per_index = 1000000);
PackedReferencePathOverlay(const PathHandleGraph* graph, size_t steps_per_index = 20000000);

// We assume that tracing out a path is fast in the backing graph, but
// finding visits on nodes is slow. We override the reverse lookups to go
Expand Down
5 changes: 4 additions & 1 deletion bdsg/src/packed_path_position_overlay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,7 @@ void PackedPositionOverlay::index_path_positions() {

// And this will be the cumulative path length of all the paths in each collection.
std::vector<size_t> path_set_steps;
size_t total_length = 0;
size_t accumulated_length = 0;
for (size_t i = 0; i < path_handles.size(); i++) {
if (accumulated_length >= steps_per_index) {
Expand All @@ -264,20 +265,22 @@ void PackedPositionOverlay::index_path_positions() {
#endif

path_set_steps.push_back(accumulated_length);
total_length += accumulated_length;
accumulated_length = 0;
}
// Remember that this path's steps went into this index.
accumulated_length += path_lengths[i];
}
bounds.push_back(path_handles.size());
path_set_steps.push_back(accumulated_length);
total_length += accumulated_length;

// Now we know how many indexes we need
this->set_index_count(path_set_steps.size());

#ifdef debug
#pragma omp critical (cerr)
std::cerr << "Using " << indexes.size() << " indexes" << std::endl;
std::cerr << "Using " << indexes.size() << " indexes for " << total_length << " total steps" << std::endl;
#endif

#pragma omp parallel for
Expand Down

0 comments on commit b5d6fdd

Please sign in to comment.