Skip to content

Speed up transitive closure and GFA emission - #143

Merged
AndreaGuarracino merged 1 commit into
masterfrom
optimize-transclosure
Jul 23, 2026
Merged

Speed up transitive closure and GFA emission#143
AndreaGuarracino merged 1 commit into
masterfrom
optimize-transclosure

Conversation

@AndreaGuarracino

Copy link
Copy Markdown
Member

Speeds up seqwish with byte-identical output.

The transitive-closure BFS deep-copied the whole seen-bitvector once per worker per chunk. That copy is quadratic in input length and dominates large runs. Sharing one &[bool] fixes it. The other changes are smaller output-preserving cleanups.

Measured (byte-identical output in every case):

input graph threads before after speedup
96 Mbp 45 Mbp 16 106s 13.5s 7.5x
197 Mbp 79 Mbp 16 447s 42.7s 11x
392 Mbp 182 Mbp 8 895s 98s 9.1x

The speedup grows with input size because the removed copy was quadratic.

Also bundled, all output-preserving:

  • range_buffer uses FxHashMap instead of SipHash (the per-base hot map)
  • skip the last_seq_pos insert when min-repeat-distance is 0 (dead work by default)
  • flush_ranges uses in-place retain (no temp Vec)
  • uppercase sequences in place on import
  • stream S-lines and format ints with itoa in GFA emission
  • byte-based CIGAR parser

Correctness: byte-identical GFA on all 28 HLA loci and yeast pangenomes up to 182 Mbp; 116 tests pass.

Share the per-chunk seen-bitvector across BFS workers by reference instead
of deep-copying it per worker. The copy was quadratic in input length
(input x chunks x workers) and dominated large runs: on a 392 Mbp yeast
pangenome (182 Mbp graph, -t8) it cuts runtime 895s -> 98s (9.1x), output
byte-identical.

Smaller output-preserving wins:
- range_buffer uses FxHashMap instead of SipHash (per-base hot map)
- skip last_seq_pos insert when min-repeat-distance is 0
- flush_ranges uses in-place retain (no temp Vec)
- uppercase sequences in place on import
- stream S-lines and format ints with itoa in GFA emission
- byte-based CIGAR parser

Byte-identical GFA across HLA (28 loci) and yeast pangenomes up to 182 Mbp.
116 tests pass.
@AndreaGuarracino
AndreaGuarracino merged commit 369b069 into master Jul 23, 2026
8 checks passed
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