perf(io): parallel order-preserving BGZF compression for BAM output - #276
Open
BenjaminDEMAILLE wants to merge 1 commit into
Open
BenjaminDEMAILLE wants to merge 1 commit into
BenjaminDEMAILLE wants to merge 1 commit into
Conversation
New BgzfWriter: the caller fills 64 KiB blocks, --runThreadN dedicated threads compress them with libdeflate, and one writer thread emits them in submission order. Output is byte-identical to noodles_bgzf at every thread count. All four BAM writers use it. finish() now writes the EOF marker and propagates errors instead of relying on drop. Refs #223 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Sep 29, 2026
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Refs #223 (option 1: parallel compression; record encoding still single-threaded).
src/io/bgzf_writer.rs: blocks are filled by the caller, compressed by--runThreadNdedicated threads (not rayon), and written in order by one thread.--runThreadN 1runs inline as before.noodles_bgzf::io::Writer: same block boundaries, libdeflate at the same level, same headers/trailers/EOF. Unit tests compare byte for byte across sizes, levels 0/1/6/12, 1/2/5 threads, irregular writes and flushes;cmpon real runs matched for BAM Unsorted, SortedByCoordinate and SAM.finish()previously called a no-op and relied on drop to write the EOF marker, discarding errors. It now writes EOF, flushes and returns errors.lib.rs,Cargo.tomlor input decoding, so it is independent of perf(align): cut the align batch size and stop cloning every FASTQ record #222, perf(pipeline): size alignment batches so the result vector stays off the arena path #261, feat(io): optional pure-Rust parallel gzip input decoding (rapidgzip-core) #225, chore(deps): bump noodles 0.113 -> 0.115, noodles-bgzf 0.49 -> 0.51 #211, chore(deps): bump noodles from 0.113.0 to 0.116.0 #259.Wall time, 2M SE 100 bp reads, synthetic 20 Mb genome, BAM Unsorted, 16-core Mac (median of 3):
At 16 threads with
--outBAMcompression 6: 5.00s → 2.92s.Follow-up (not here): move BAM record encoding into the parallel align stage (conflicts with #222/#261), and
bam_dedup.rs's own writer.Tests: fmt, clippy 0 warnings,
cargo test636 passed.🤖 Generated with Claude Code