Accelerate integer primitives and expand performance coverage - #1021
Merged
Merged
Conversation
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR improves hot-path MessagePack integer primitive encoding/decoding and broadens the repository’s performance coverage by adding new BenchmarkDotNet suites and updating the accompanying performance docs/workflow guidance.
Changes:
- Optimized
intfixint write path and added a fast-pathInt32reader for fixint andInt32/UInt32payload forms. - Added/expanded performance benchmarks (integer distributions, default-settings POCO comparisons, and a larger data model scenario) plus refreshed performance documentation/report notes.
- Added primitive codec tests covering
Int32fixint,Int32payload, insufficient buffer behavior, and unsigned overflow behavior.
Reviewed changes
Copilot reviewed 13 out of 13 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| test/Nerdbank.MessagePack.Tests/MessagePackPrimitivesTests.cs | Adds targeted primitive decoding tests for Int32 to validate optimized paths and edge cases. |
| test/Benchmarks/update-benchmarks-report.ps1 | Updates the benchmark-report workflow guidance to current BenchmarkDotNet invocation patterns. |
| test/Benchmarks/SimplePoco.cs | Adds default-settings POCO benchmarks alongside existing configured-serializer comparisons. |
| test/Benchmarks/LargeDataModelBenchmark.cs | Introduces a larger data-model benchmark for more realistic serialize/deserialize throughput/allocation tracking. |
| test/Benchmarks/IntegerPrimitives.cs | Adds branch-sensitive integer primitive benchmarks with diagnosers/counters for repeatable perf analysis. |
| src/Nerdbank.MessagePack/MessagePackPrimitives.Writers.cs | Optimizes int fixint encoding by collapsing positive/negative fixint handling into a single fast check. |
| src/Nerdbank.MessagePack/MessagePackPrimitives.Readers.Integers.tt | Updates the T4 template to emit the Int32 fast-path reader logic and a non-inlined fallback. |
| src/Nerdbank.MessagePack/MessagePackPrimitives.Readers.Integers.cs | Implements the generated Int32 fast-path reader plus a no-inlining fallback helper. |
| src/Nerdbank.MessagePack/Converters/EnumerableConverter`2.cs | Reduces allocations/overhead by special-casing List<T> writes via a no-inlined concrete path. |
| src/Nerdbank.MessagePack/Converters/DictionaryConverter`3.cs | Special-cases Dictionary<TKey,TValue> enumeration via a no-inlined concrete path. |
| docfx/includes/perf.md | Refreshes performance report content/axes and adds clarifying provenance text. |
| docfx/docs/performance.md | Updates narrative guidance around relative performance comparisons and benchmark interpretation. |
| AGENTS.md | Documents the perf optimization workflow/benchmark baseline commands for contributors and agents. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
This was referenced Aug 27, 2026
This was referenced Sep 3, 2026
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 improves hot MessagePack integer encoding and decoding paths while establishing broader, repeatable performance coverage for future optimization work.
The integer benchmarks use fixed-seed Small, Mixed, and Large workloads to make branch-sensitive results reproducible. Hardware-counter collection requires an elevated Windows process.