Skip to content

Keep a BAM record's stored bytes when a tag it doesn't have is removed - #1955

Open
tfenne wants to merge 1 commit into
tf_bam_codec_benchmarkfrom
tf_absent_tag_removal_keeps_bam_bytes
Open

tfenne wants to merge 1 commit into
tf_bam_codec_benchmarkfrom
tf_absent_tag_removal_keeps_bam_bytes

Conversation

@tfenne

@tfenne tfenne commented Oct 30, 2026

Copy link
Copy Markdown
Member

Removing a tag a BAM record doesn't have no longer makes the record re-encode on write. Stacked on #1954, which adds the benchmark.

  • BAMRecord.setAttribute(tag, null) marked the stored variable-length bytes stale even when the tag was absent, so writing the record back to BAM decoded and re-encoded name, CIGAR, bases, qualities and tags. Duplicate marking clears DT on every read.
  • It now returns early when there is nothing to remove.
  • BamRecordCodecBenchmark, 3 forks a side: re-encoding after such a removal 75.2 → 35.9 ms for 200,000 150 bp reads (-52%; what remains is decoding the tags to look for it) and 16.6 → 1.85 ms for 2,000 15 kb reads (-89%). Controls: tag set +3.7% (t=2.3), untouched +3.5% (t=0.9), on a machine where most forks reported outside load.
  • New BAMRecordTest, as BAMRecord had no test class.

setAttribute(tag, null) marked a BAMRecord's stored variable-length
bytes stale even when the record had no such tag, so writing it back to
BAM decoded and re-encoded the name, CIGAR, bases, qualities and tags
although nothing had changed. Duplicate marking clears DT on every read,
so every read paid that.

Removing an absent tag now leaves the bytes alone. In
BamRecordCodecBenchmark (3 forks a side) re-encoding after such a
removal fell from 75.2 to 35.9 ms for 200,000 150 bp reads with typical
tags (-52%; the remaining cost is decoding the tags to look for it) and
from 16.6 to 1.85 ms for 2,000 15 kb reads (-89%). Setting a tag moved
+3.7% (t=2.3) and an untouched re-encode +3.5% (t=0.9), within this
machine's noise.
@coderabbitai

coderabbitai Bot commented Oct 30, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 0fbe3b15-b859-4c75-9c2d-0ca2077001b2

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

This branch has not been deployed

No deployments
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