Skip to content

feat(streaming): configure memory stream dequeue limits - #11238

Merged
ReubenBond merged 1 commit into
dotnet:mainfrom
ReubenBond:rb-feat-configure-memory-cache-batches
Sep 10, 2026
Merged

ReubenBond merged 1 commit into
dotnet:mainfrom
ReubenBond:rb-feat-configure-memory-cache-batches

Conversation

@ReubenBond

@ReubenBond ReubenBond commented Sep 10, 2026 •

Copy link
Copy Markdown
Member

Problem

Memory streams request a fixed 100 queue records per dequeue. Combining large records into one queue-grain response can exceed the configured message-body limit after those records have been removed from the queue. Applications need a per-provider record limit to tune response sizes and queue-call overhead.

Solution

Add named MemoryStreamCacheOptions.MaxAddCount, defaulting to 100, with positive-value validation at startup. Configure it through ConfigureCache on the silo memory-stream configurator or through the named provider's configuration section.

Pass the configured count from MemoryAdapterFactory into MemoryPooledCache and expose it through IQueueFlowController.GetMaxAddCount(). Preserve the existing cache constructor and its default behavior, and add an overload for direct cache construction.

Document the throughput/response-size tradeoff and the record-count semantics: aggregate response bytes depend on serialized record payloads. Include coverage for defaults, custom values, named-provider isolation, validation, configuration binding, receiver dequeue bounds, and constructor compatibility, plus the regenerated public API surface.

Microsoft Reviewers: Open in CodeFlow

Copilot AI lite review requested due to automatic review settings September 10, 2026 21:06

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

The change is narrowly scoped, preserves existing defaults/constructors, adds validation, updates docs, and includes targeted tests for configuration flow and dequeue bounds.

Review tier: Lite
Findings: None

What changed in this PR

This PR adds a per-provider configuration knob for Orleans memory streams to limit the number of queue records requested per dequeue, helping applications avoid oversized dequeue responses (and associated message-body limit failures) while allowing tuning of throughput vs call overhead.

Changes:

  • Introduces MemoryStreamCacheOptions.MaxAddCount (default 100) with named options + startup validation.
  • Plumbs MaxAddCount through MemoryAdapterFactory into MemoryPooledCache and IQueueFlowController.GetMaxAddCount().
  • Adds docs and test coverage for defaults, configuration, validation, named-provider isolation, and constructor compatibility, plus regenerated public API.
File Description
test/​Orleans.Streaming.Tests/​OrleansRuntime/​Streams/​MemoryStreamCacheOptionsTests.cs Adds tests covering default behavior, configuration flow, validation, and dequeue bounds.
src/​Orleans.Streaming/​MemoryStreams/​MemoryStreamProviderBuilder.cs Binds named provider configuration sections to MemoryStreamCacheOptions for config-based registration.
src/​Orleans.Streaming/​MemoryStreams/​MemoryStreamCacheOptions.cs Adds new options type with documented semantics and default value.
src/​Orleans.Streaming/​MemoryStreams/​MemoryStreamBuilder.cs Adds ConfigureCache extension and startup validation/logging for the new named options.
src/​Orleans.Streaming/​MemoryStreams/​MemoryPooledCache.cs Stores configured max-add count and exposes it via GetMaxAddCount(); preserves existing constructor behavior.
src/​Orleans.Streaming/​MemoryStreams/​MemoryAdapterFactory.cs Reads MemoryStreamCacheOptions by provider name and passes the configured limit into the cache.
src/​api/​Orleans.Streaming/​Orleans.Streaming.cs Updates generated public API surface for the new options and overloads.
docs/​site/​src/​content/​docs/​streaming/​streaming-operations.md Documents the new tuning option and the throughput vs response-size tradeoff.
docs/​site/​src/​content/​docs/​streaming/​stream-providers.md Links to the tuning guidance from the memory streams provider docs.

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

@ReubenBond
ReubenBond merged commit 025bf9e into dotnet:main Sep 10, 2026
66 of 67 checks passed
@ReubenBond
ReubenBond deleted the rb-feat-configure-memory-cache-batches branch September 10, 2026 21:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants