Skip to content

Speed up PackedGraph construction - #244

Merged
glennhickey merged 2 commits into
masterfrom
faster-packedgraph
Oct 6, 2026
Merged

glennhickey merged 2 commits into
masterfrom
faster-packedgraph

Conversation

@glennhickey

Copy link
Copy Markdown
Contributor

Making PackedGraphs (for modifyting with vg) is becoming a bottleneck in minigraph-cactus. Here is a relatively simple change that gets about 3X speedup on some tests:

From Claude:

Stop PackedVector growth from copying every element through the bit-p…acked accessors

PackedVector grows its capacity by 1.25x, and each growth went through repack(), which built a new int_vector and copied every element across through sdsl's reference proxies -- even when the width was unchanged and a realloc would do. New pages of a PagedVector also start 1 bit wide and widen several times, each widening another full proxy copy, and every growth then zeroed its new entries one at a time.

  • repack() at an unchanged width now just resizes the int_vector
  • widening uses sdsl::util::expand_width, which works in place on raw words
  • new entries are zeroed a word at a time (the mapped backend keeps the per-element loop)

Stored contents, widths and serialized bytes are unchanged.

…acked accessors

PackedVector grows its capacity by 1.25x, and each growth went through
repack(), which built a new int_vector and copied every element across
through sdsl's reference proxies -- even when the width was unchanged
and a realloc would do.  New pages of a PagedVector also start 1 bit
wide and widen several times, each widening another full proxy copy,
and every growth then zeroed its new entries one at a time.

- repack() at an unchanged width now just resizes the int_vector
- widening uses sdsl::util::expand_width, which works in place on raw words
- new entries are zeroed a word at a time (the mapped backend keeps the
  per-element loop)

Stored contents, widths and serialized bytes are unchanged.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
CMakeLists.txt moved to C++20 with the contraction hierarchy code (ch.hpp
uses operator<=> and std::ranges), but the Makefile still asked for
C++17, so a plain `make` no longer builds.  vg is unaffected, since it
appends its own -std=c++20 after ours, but libbdsg-easy uses the
Makefile's default.

CompatIntVector's out-of-line begin()/end() also need `typename` on
their dependent return type before C++20, which broke anything including
packed_graph.hpp at an older standard.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@glennhickey
glennhickey merged commit b6d327d into master Oct 6, 2026
1 check passed
adhirakunnath-hue pushed a commit to adhirakunnath-hue/vg that referenced this pull request Oct 21, 2026
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
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

Successfully merging this pull request may close these issues.

1 participant