Skip to content

format SAM/PAF records with inline appenders - #5

Draft
nh13 wants to merge 1 commit into
masterfrom
feat/inline-appenders
Draft

format SAM/PAF records with inline appenders#5
nh13 wants to merge 1 commit into
masterfrom
feat/inline-appenders

Conversation

@nh13

@nh13 nh13 commented Jun 25, 2026

Copy link
Copy Markdown
Owner

Recreated from lh3/minibwa#32, which Heng closed unmerged on 2026-06-24.
Heng's closing rationale: "No visible improvement to CPU time on my mac. This PR might matter under -t96, but that is a rare use case."
Recreated as a draft in this fork (nh13/minibwa) for continued development and review.


Each record made ~20 kom_sprintf_lite() calls, every one re-parsing a format string and setting up a va_list. Replace them in the per-record formatters (mb_fmt_sam, mb_fmt_paf, write_tags, write_sam_cigar) with inline appenders that emit the same bytes directly; the once-per-file header builders are left as is.

About 39% less encode CPU at t=1 on a 300k-pair set. Output is byte-identical across the SAM/PAF + tag matrix (SA:Z, secondary, indels, soft/hard clip, MC/MD/cs/ds, RG, comments).

@nh13 nh13 added the feature review vehicle for a manifest feature; never a merge vehicle label Aug 3, 2026
Each record made ~20 kom_sprintf_lite() calls, every one re-parsing a
format string and setting up a va_list. Replace them in the per-record
formatters (mb_fmt_sam, mb_fmt_paf, write_tags, write_sam_cigar) with
inline str_putc/str_puts/str_puti/str_putu that emit the same bytes
directly; the once-per-file header builders are left as is. About 39%
less encode CPU at t=1; output is unchanged.
@nh13
nh13 force-pushed the feat/inline-appenders branch from 8dd52d2 to 2121575 Compare August 7, 2026 20:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature review vehicle for a manifest feature; never a merge vehicle

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant