Skip to content

perf: optimize EventHub cache mapping - #10767

Merged
ReubenBond merged 1 commit into
dotnet:mainfrom
ReubenBond:rb-optimize-eventhub-cache-data-mapping
Aug 22, 2026
Merged

ReubenBond merged 1 commit into
dotnet:mainfrom
ReubenBond:rb-optimize-eventhub-cache-data-mapping

Conversation

@ReubenBond

@ReubenBond ReubenBond commented Aug 22, 2026 •

Copy link
Copy Markdown
Member

Problem

Issue #1742 identified unnecessary work when mapping Event Hubs EventData application properties into and out of the pooled stream cache. Orleans-produced messages normally contain only the internal StreamNamespace property, which is excluded from the cached application-property collection, but the adapter still serialized and deserialized an empty list for every message.

Solution

Represent an empty application-property collection as a zero-length cache segment and construct the mutable empty dictionary directly when reading it. For messages with application properties, populate the serialized list and reconstructed dictionary with allocation-conscious loops instead of LINQ.

The representation is internal to each silo's in-memory cache, so it introduces no durable wire-format compatibility requirement. Application properties, duplicate-key errors, and the mutable IDictionary contract are preserved.

Performance

BenchmarkDotNet on .NET 10 for the default no-application-properties path measured serialization improving from 117.6 ns / 128 B to 7.1 ns / 0 B, and deserialization improving from 74.6 ns / 112 B to 13.7 ns / 80 B. Messages with application properties retain equivalent throughput while the serialization-side temporary allocation drops from 280 B to 232 B for four properties.

Related to #1742.

Microsoft Reviewers: Open in CodeFlow

Copilot AI lite review requested due to automatic review settings August 22, 2026 07:41

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.

Pull request overview

Optimizes Event Hubs application-property mapping in the in-memory stream cache to reduce allocations.

Changes:

  • Uses zero-length cache segments for empty properties.
  • Replaces LINQ mapping with allocation-conscious loops.
  • Adds empty and round-trip mapping tests.
Show a summary per file
File Description
test/Extensions/Orleans.Streaming.EventHubs.Tests/EventHubDataAdapterTests.cs Tests property mapping behavior.
src/Azure/Orleans.Streaming.EventHubs/Providers/Streams/EventHub/EventDataExtensions.cs Optimizes property serialization and deserialization.

Review details

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

  • Files reviewed: 2/2 changed files
  • Comments generated: 0
  • Review effort level: Lite

@ReubenBond
ReubenBond merged commit 51e3f10 into dotnet:main Aug 22, 2026
79 checks passed
@ReubenBond
ReubenBond deleted the rb-optimize-eventhub-cache-data-mapping branch August 22, 2026 15:23
This was referenced Aug 28, 2026
@github-actions github-actions Bot locked and limited conversation to collaborators Sep 22, 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