[repo-assist] perf: add AggressiveInlining to Square; add Add/Subtract/FromDecimal benchmarks - #215
Draft
github-actions[bot] wants to merge 1 commit into
Conversation
…benchmarks FixedPointNano.cs: - Add [MethodImpl(MethodImplOptions.AggressiveInlining)] to Square(). The method is a single-expression wrapper around operator * and is an obvious inlining candidate on hot arithmetic paths. FixedPointNanoMathBenchmarks.cs: - Add AddRaw / AddDecimalReference / AddDoubleReference benchmarks. Addition is the most-common operation in accumulation loops (e.g. SMA, VWAP) and was the only arithmetic operator without an isolated benchmark. - Add SubtractRaw / SubtractDecimalReference / SubtractDoubleReference — same gap for subtraction. - Add FromDecimalRaw — benchmarks the direct decimal construction path, complementing the existing FromDoubleRaw benchmark. All 1426 existing tests continue to pass. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
13 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🤖 This PR was created by Repo Assist, an automated AI assistant.
Summary
Two small, targeted improvements to the
mainbranch:[MethodImpl(MethodImplOptions.AggressiveInlining)]onSquareAdd,Subtract, andFromDecimalChanges
src/FixedPointNano/FixedPointNano.csSquare—AggressiveInliningSquareis a single-expression wrapper aroundoperator *:It was the only short arithmetic helper without the attribute. The hint allows the JIT to eliminate the call frame when
Squareappears in a hot loop (e.g. Bollinger band accumulation).benchmarks/FixedPointNano.Benchmarks/FixedPointNanoMathBenchmarks.csAdded 7 benchmarks:
AddRawFixedPointNano + FixedPointNanoAddDecimalReferencedecimal + decimal→FromDecimalAddDoubleReferencedouble + doubleSubtractRawFixedPointNano - FixedPointNanoSubtractDecimalReferencedecimal - decimal→FromDecimalSubtractDoubleReferencedouble - doubleFromDecimalRawFpn.FromDecimal(decimal)in isolationAddition and subtraction are the most frequently executed operations in accumulation loops — yet had no isolated benchmark.
FromDecimalwas only measured as part of thedecimal-reference paths, never directly.Trade-offs
AggressiveInliningonSquarecarries a marginal code-size cost at large call-sites, but the method body is a single multiplication — well within typical inlining size limits.Test Status
Build: ✅ Tests: ✅ (1426 passing, 0 failures)
Add this agentic workflows to your repo
To install this agentic workflow, run