Repository navigation
concat: copy unchanged BGZF blocks instead of recompressing - #2618
Open
BenjaminDEMAILLE wants to merge 1 commit into
Open
BenjaminDEMAILLE wants to merge 1 commit into
BenjaminDEMAILLE wants to merge 1 commit into
Conversation
For a plain concat (no -a/-l/-G/-W or compression level) of inputs in the output's BGZF format whose records need no change, still read and check the records but copy the original compressed blocks. CRLF, no final newline, read errors or different BCF dictionaries fall back to the old path. Decompressed output is identical; block boundaries differ. Reuses the --naive block copy loop. Idea from pasta (https://github.com/DylanCosto/pasta, MIT). Assisted-by: Claude:claude-opus-5-5 Signed-off-by: Benjamin Demaille <benjamin.demaille@icloud.com>
BenjaminDEMAILLE
force-pushed
the
perf/concat-copy-blocks
branch
2 times, most recently
from
November 24, 2026 09:46
1dbcc5f to
bad3b88
Compare
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.
I noticed that plain
bcftools concatdecompresses and recompresses everything, even when no record changes. With this change I still read and check the records (same order checks and errors), but I copy the original BGZF blocks to the output. Only the part that shares a block with the header gets recompressed.I only use it per input when there's no
-a/-l/-G/-Wand no explicit level, the input is a regular BGZF file of the same format as the output, and, for BCF, the header IDs match. Anything odd (CRLF, no final newline, read errors) falls back to the current path. The decompressed output is identical to develop; only the block boundaries differ. I factored out the--naiveblock copy loop and reuse it.Concatenating 4 chunks of 1000G chr22 went from 2.76s to 0.18s for VCF.gz and from 2.38s to 0.15s for BCF on my machine. The output gets about 0.03% bigger.
make testpasses. I madetest_vcf_concatalso check-Oz, and addedconcat.7to cover the fallbacks.I adapted the idea from pasta (https://github.com/DylanCosto/pasta, MIT).
I've listed this with my other performance PRs in samtools/htslib#2175.
Assisted-by: Claude:claude-opus-5-5