Skip to content

qv: inline the renormalizations on NEON - #118

Merged
nmoinvaz merged 1 commit into
mainfrom
perf/neon-qv-renorm-inline
Nov 19, 2026
Merged

nmoinvaz merged 1 commit into
mainfrom
perf/neon-qv-renorm-inline

Conversation

@nmoinvaz

@nmoinvaz nmoinvaz commented Nov 19, 2026 •

Copy link
Copy Markdown
Owner

On NEON, Simd::hot only hints, so renorm4 and renorm5 compiled as functions of their own, and each call stored its 16 input registers and loaded its 16 output registers through the stack. The new Simd::hot_renorm forces them inline on NEON and is hot on every other backend. The results are unchanged bit for bit.

Cycles on an Apple M5 with native QV, new over main, minimum of five interleaved runs:

Op Ratio
add 0.85
mul 0.89
div 0.94
sqrt 0.94
ieee_add 0.97
dot 1.01

The release test build takes 560 s of CPU and 1.0 GB at peak, against 536 s and 1.4 GB. Forcing every hot operation inline on NEON would also take div and sqrt to about 0.86, but it raises the build to 2117 s and 4.6 GB.

Summary by CodeRabbit

  • Performance
    • Optimized vector renormalization on supported CPU architectures.

Out of line, the renormalizations passed their four lane vectors of four registers each through memory both ways
on every call. Simd::hot_renorm forces them inline on NEON, which makes QV addition about 15% and multiplication
about 11% faster on an Apple M5, with the results unchanged bit for bit.
@nmoinvaz nmoinvaz added the optimization Performance optimization label Nov 19, 2026
@coderabbitai

coderabbitai Bot commented Nov 19, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The Simd trait adds hot_renorm, and the NEON backend implements it. The renorm4 and renorm5 functions now use this hook instead of Simd::hot.

Changes: Renormalization inlining

Layer / File(s) Summary
Define renormalization inlining hooks
src/simd.rs, src/v8.rs
Simd adds the always-inlined hot_renorm method, which delegates to Self::hot. The NEON backend adds an implementation that invokes the closure directly.
Route qv renormalizations through the hook
src/qv.rs
renorm4 and renorm5 use Simd::hot_renorm. The inlining comment now describes its use on NEON.

Estimated code review effort: 2 (Simple) | ~8 minutes

Suggested labels: optimization

Suggested reviewers: claude

Merge Risk: Minimal · up to 5da0e

This change inlines the QV renormalization functions on NEON to speed up addition and multiplication. Results are reported as unchanged, and no concrete merge risk was found.

Pre-merge checks: Passed 4

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title "qv: inline the renormalizations on NEON" matches the main change. The PR changes Simd::hot_renorm so renorm4 and renorm5 are forced inline on NEON, and the added hot_renorm method and NEON …
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title "qv: inline the renormalizations on NEON" matches the main change. The PR changes Simd::hot_renorm so renorm4 and renorm5 are forced inline on NEON, and the added hot_renorm method and NEON wrapper in src/v8.rs implement that. The title is short, specific, and names the backend and the operation.

Finishing Touches

Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Recent review info

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: Essentials
  • Run ID: 6c234e5b-fc27-447f-ab14-9534c44fa3fa
Commits

Reviewing files that changed from the base of the PR and between 3ea2616 and 5da0eb1.

Files selected for processing: 3

  • src/qv.rs
  • src/simd.rs
  • src/v8.rs

Included review availability: This review used your included allowance. 0 included reviews remain after this review. Your included PR review attempts over the past 7 days set your current allowance at 1 review per hour.

@greptile-apps

greptile-apps Bot commented Nov 19, 2026 •

Copy link
Copy Markdown

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] This PR appears safe to merge.

Summary

This PR forces QV renormalization helpers to inline on NEON while keeping the existing inlining choices on other backends.

  • NEON QV arithmetic now inlines its renormalization steps.

Reviews (1) · Last reviewed commit: "qv: inline the renormalizations on NEON" · Reviewed by Greptile

@nmoinvaz
nmoinvaz merged commit f9ef383 into main Nov 19, 2026
37 checks passed
@nmoinvaz
nmoinvaz deleted the perf/neon-qv-renorm-inline branch November 19, 2026 20:16
@codecov

codecov Bot commented Nov 19, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.12%. Comparing base (3ea2616) to head (5da0eb1).
⚠️ Report is 2 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #118   +/-   ##
=======================================
  Coverage   97.12%   97.12%           
=======================================
  Files          22       22           
  Lines       14037    14040    +3     
=======================================
+ Hits        13633    13636    +3     
  Misses        404      404           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

optimization Performance optimization

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant