8000 perf(extd2): double-buffer the arm64 DP rails to drop the vext shifts by nh13 · Pull Request #44 · nh13/minibwa · GitHub
[go: up one dir, main page]

Skip to content

perf(extd2): double-buffer the arm64 DP rails to drop the vext shifts - #44

Draft
nh13 wants to merge 1 commit into
perf/ksw2-extension-kernelsfrom
perf/extd2-neon-v2
Draft

nh13 wants to merge 1 commit into
perf/ksw2-extension-kernelsfrom
perf/extd2-neon-v2

Conversation

@nh13
@nh13 nh13 commented Sep 7, 2026
Copy link
Copy Markdown
Owner

What

Optimizes minibwa's #1 aligner hotspot — the extd2 dual-gap (two-piece affine, Suzuki-Kasahara) Smith-Waterman extension kernel — on arm64/NEON only, on top of the existing perf/ksw2-extension-kernels feature.

The x/v/x2 DP rails are double-buffered by row parity, so the t-1 shifted rails become plain unaligned loads from the previous row's padded buffer instead of a vext shift + carry-move per rail per inner iteration (three of each removed). The row boundary byte is inserted with a single lane-0 write. A macro layer (__dp_store_*, __dp_u8/__dp_v8, __dp_code_block3) lets the two kernels share the loop bodies.

Gated by KSW_EXTD2_NEON_KERNEL, which is set only under __ARM_NEON. On x86/SSE the original single-buffer kernel is used verbatim, because there the shift is already a single cheap _mm_alignr_epi8 and double-buffering mildly regresses short reads — the same arm64-only guarding rationale used elsewhere in the ksw2 kernels. The rails store identical values on both paths, so output is byte-identical to the current kernel on both ISAs.

Performance (bwa-bsw-bench, arm64 Graviton4 c8g, best-of-7 ×2)

qlen baseline Mc/s candidate Mc/s wide x
100 1390 1442 1.04×
150 1720 1843 1.07×
250 2000 2195 1.10×

x86 (c6a, AVX2 host): neutral (1.00×), byte-identical — the guard leaves the x86 path unchanged.

Correctness

  • ./sw_bench --check --mode extd2: PASS — 120,000 pairs identical in score and CIGAR.
  • A 104,680-call differential harness (KSW_EXTD2_NEON_KERNEL=0 vs =1, same source) with 0 divergences, deliberately sweeping q+e/q2+e2 past the int8 overflow edge (10k+ draws with qe+qe2 > 128) so the byte-identity holds across the full parameter domain, not just realistic scoring.
  • Full-aligner SAM byte-identity vs the baseline kernel across default / -u / -b MD / single-end on real WGS reads (~100k records each), on both arm64 and x86.

Draft, feature-labeled review vehicle — installation is the manifest's job, not this PR.

On arm64, double-buffer the x/v/x2 rails by row parity so the t-1 shifted
rails become plain unaligned loads from the previous row's padded buffer,
removing three vext rail-shifts and three carry moves per inner iteration.
The row boundary byte is inserted with a single lane-0 write (ksw_insert0).

Gated by KSW_EXTD2_NEON_KERNEL (set only under __ARM_NEON): x86/SSE keeps the
original single-buffer path, where the alignr shift is already one cheap op and
double-buffering regresses short reads. A macro layer lets both kernels share
the loop bodies, and the rails store identical values on both paths, so the
arm64 output is byte-identical to stock across the full int8 parameter domain
-- verified by a 104k-call differential sweep that deliberately spans q+e and
q2+e2 past the int8 overflow edge, plus bench --check (120k pairs) and
full-aligner SAM identity on real reads across four flag modes on both arches.

+4-11% on the extd2 dual-gap kernel on Graviton4 at qlen 100/150/250, and
neutral/byte-identical on x86 -- the #1 aligner hotspot.
@nh13 nh13 added feature review vehicle for a manifest feature; never a merge vehicle uninstalled No features.toml block yet; not installed into the distribution (dist). Remove when installed. labels Sep 7, 2026
@coderabbitai
coderabbitai Bot commented Sep 7, 2026 •
Copy link
Copy Markdown

Note

Reviews paused

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true

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.

@nh13
nh13 commented Sep 7, 2026
Copy link
Copy Markdown
Owner Author

@coderabbitai pause

@coderabbitai
coderabbitai Bot commented Sep 7, 2026
Copy link
Copy Markdown
✅ Action performed

Reviews paused.

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 uninstalled No features.toml block yet; not installed into the distribution (dist). Remove when installed.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

0