Skip to content

[repo-assist] perf: add [AggressiveInlining] to Frac and Lerp; add Lerp and Clamp benchmarks - #219

Draft
github-actions[bot] wants to merge 1 commit into
mainfrom
repo-assist/perf-frac-lerp-inlining-2026-07-06-24e434fa7cb1abde
Draft

[repo-assist] perf: add [AggressiveInlining] to Frac and Lerp; add Lerp and Clamp benchmarks#219
github-actions[bot] wants to merge 1 commit into
mainfrom
repo-assist/perf-frac-lerp-inlining-2026-07-06-24e434fa7cb1abde

Conversation

@github-actions

@github-actions github-actions Bot commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

🤖 This PR was created by Repo Assist, an automated AI assistant.

Summary

Adds [MethodImpl(MethodImplOptions.AggressiveInlining)] to two public helpers that were missing it, and extends the benchmark suite with Lerp and Clamp measurements.

Changes

src/FixedPointNano/FixedPointNano.cs

  • Frac: was the only short hot-path math helper without [AggressiveInlining]. Its sibling FractionalPart (identical implementation, different name) already carries the attribute. Adding it to Frac makes the two consistent.
  • Lerp: a three-operation composable helper (start + (end-start) * amount). Like the arithmetic operators, it is short enough that inlining into hot loops avoids function-call overhead.

benchmarks/FixedPointNano.Benchmarks/FixedPointNanoMathBenchmarks.cs

Five new benchmarks completing coverage of the main public math surface:

Benchmark What it measures
LerpDecimalReference Lerp via decimal round-trip
LerpDoubleReference Lerp via double (FP baseline)
LerpRaw Fpn.Lerp — fixed-point path
ClampDecimalReference Math.Clamp(decimal) round-trip
ClampRaw Fpn.Clamp — raw comparison path

Clamp is expected to be the fastest of all benchmarks: three raw comparisons with no arithmetic.

Rationale

Consistent inlining hints reduce JIT overhead in tight loops. The benchmark additions let maintainers see exactly how these methods compare to the decimal baseline, consistent with every other math helper in the suite.

Test Status

✅ Build succeeded — 0 warnings, 0 errors
✅ Tests passed — 1426/1426 (no behaviour change)

Generated by 🌈 Repo Assist, see workflow run. Learn more.

Add this agentic workflows to your repo

To install this agentic workflow, run

gh aw add githubnext/agentics/workflows/repo-assist.md@e15e57b40918dbca11b350c55d02ab61934afa75

…enchmarks

- Frac was the only short hot-path helper lacking [AggressiveInlining]; its
  sibling FractionalPart (identical implementation) already has the attribute.
- Lerp is a three-operation composable helper (start + (end-start) * amount)
  that benefits from inlining into call sites.
- Add LerpDecimalReference, LerpDoubleReference, LerpRaw benchmarks.
- Add ClampDecimalReference, ClampRaw benchmarks.
  These complete the coverage of the main public math helpers in the benchmark
  suite; only Pow, PopulationVariance/SampleVariance, and Parse remain.

Tests: 1426/1426 passed.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants