perf(ParseResults.getAllResults): Drop Seq pipeline for direct buffer#319
Open
dimension-zero wants to merge 1 commit into
Open
perf(ParseResults.getAllResults): Drop Seq pipeline for direct buffer#319dimension-zero wants to merge 1 commit into
dimension-zero wants to merge 1 commit into
Conversation
The previous implementation chained
Seq.concat -> Seq.filter -> Seq.sortBy -> Seq.map -> Seq.toList,
allocating an enumerator + closure per stage. Replace with a single
ResizeArray fill, one System.Array.Sort using the same source-priority
key, and a typed projection into a final list. Two arrays total instead
of five-ish Seq wrappers.
* Behaviour preserved byte-identical: same filter predicate, same
sort key (((int Source) <<< 16) + Index), same final shape ('Template
list).
* Hot path: this is called by GetAllResults, ToString, Equals,
GetHashCode (via CachedAllResults), and IComparable.CompareTo. Each
hit saves ~4 wrapper allocations.
* All 112 tests pass unchanged.
A proper benchmark belongs in benchmarks/Argu.Benchmarks (added by
pr/25-benchmark-harness); allocation deltas will be measured there
once both branches merge to master.
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.
perf(ParseResults.getAllResults): Drop Seq pipeline for direct buffer
The previous implementation chained
Seq.concat -> Seq.filter -> Seq.sortBy -> Seq.map -> Seq.toList,
allocating an enumerator + closure per stage. Replace with a single
ResizeArray fill, one System.Array.Sort using the same source-priority
key, and a typed projection into a final list. Two arrays total instead
of five-ish Seq wrappers.
sort key (((int Source) <<< 16) + Index), same final shape ('Template
list).
GetHashCode (via CachedAllResults), and IComparable.CompareTo. Each
hit saves ~4 wrapper allocations.
A proper benchmark belongs in benchmarks/Argu.Benchmarks (added by
pr/25-benchmark-harness); allocation deltas will be measured there
once both branches merge to master.