Skip to content

perf(serialization): read contiguous JSON payloads directly - #11270

Merged
ReubenBond merged 2 commits into
dotnet:mainfrom
ReubenBond:rb-perf-reduce-runtime-overhead
Sep 16, 2026
Merged

ReubenBond merged 2 commits into
dotnet:mainfrom
ReubenBond:rb-perf-reduce-runtime-overhead

Conversation

@ReubenBond

@ReubenBond ReubenBond commented Sep 16, 2026 •

Copy link
Copy Markdown
Member

Problem

JsonCodec.ReadValue stages every JSON payload in a PooledBuffer before deserializing it, even when the reader already exposes the complete payload as a contiguous span. That adds a payload-sized copy and pooled-buffer operations on each non-reference read.

Solution

Use Reader.TryReadBytes to initialize Utf8JsonReader directly over contiguous input. Continue using the existing pooled sequence path for payloads spanning segments and for stream input. Both paths share JSON reader/serializer options, native JsonNode handling, and reference bookkeeping.

The change follows the existing direct-read pattern in StringCodec. Its benefit scales with payload size while keeping the wire format and public API stable. Focused coverage checks all input shapes, options, reference identity, native JSON nodes, and that contiguous JSON tokens overlap the original input buffer. No throughput claim is made without workload measurements.

Microsoft Reviewers: Open in CodeFlow

Copilot AI lite review requested due to automatic review settings September 16, 2026 07:15

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟢 Approval recommended

No unresolved review comments remain, and focused coverage supports the changes.

Review tier: Lite
Findings: None

What changed in this PR

Optimizes JSON deserialization by reading contiguous payloads directly while preserving segmented and stream fallbacks.

Changes:

  • Added direct contiguous-span parsing.
  • Expanded coverage for input shapes, options, references, JSON nodes, and buffer overlap.
File Summary
test/​Orleans.Serialization.UnitTests/​JsonCodecTests.cs Verifies supported input formats and options.
src/​Orleans.Serialization.SystemTextJson/​JsonCodec.cs Parses contiguous JSON payloads directly.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Copilot AI review requested due to automatic review settings September 16, 2026 07:20

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟢 Approval recommended

No unresolved blocking issues were identified.

Review tier: Lite
Findings: None

@github-actions

Copy link
Copy Markdown
Contributor

Code coverage

Metric Pull request
Lines 82.05% (111,957 / 136,449)
Branches 71.19% (32,162 / 45,180)

Report-only conclusion: current-main baseline stale.

The newest successful coverage run tested 3604a08, not current main 9222be9.

Coverage combines every CI test matrix job, including providers, CodeGen, .NET 8/10, Linux, Windows, and macOS, using canonical physical source and branch identities.

The comparison remains report-only while normal line and branch variance is calibrated.

Coverage details

@ReubenBond
ReubenBond merged commit b92f08a into dotnet:main Sep 16, 2026
73 checks passed
@ReubenBond
ReubenBond deleted the rb-perf-reduce-runtime-overhead branch September 16, 2026 15:29
This was referenced Oct 12, 2026
@github-actions github-actions Bot locked and limited conversation to collaborators Oct 17, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants