perf(runtime): lazily allocate activation request tracking#10115
Draft
ReubenBond wants to merge 1 commit into
Draft
perf(runtime): lazily allocate activation request tracking#10115ReubenBond wants to merge 1 commit into
ReubenBond wants to merge 1 commit into
Conversation
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR reduces per-activation allocations in the Orleans runtime by lazily creating (and reusing) the collections used to track queued and running requests for an activation, while keeping existing “no requests” semantics intact.
Changes:
- Lazily allocate
_waitingRequestsand_runningRequestsinActivationDataand update related logic to be null-safe. - Introduce shared pools for the request-tracking collections and return them for reuse when they become empty.
Show a summary per file
| File | Description |
|---|---|
src/Orleans.Runtime/Catalog/GrainTypeSharedContext.cs |
Adds shared pools plus rent/return helpers for request-tracking collections. |
src/Orleans.Runtime/Catalog/ActivationData.cs |
Switches request tracking to lazy allocation, adds return-to-pool logic, and updates null-safe request-count/inactivity checks. |
Copilot's findings
- Files reviewed: 2/2 changed files
- Comments generated: 1
Comment on lines
+24
to
+25
| private static readonly ConcurrentStack<Dictionary<Message, CoarseStopwatch>> RunningRequestsMapPool = new(); | ||
| private static readonly ConcurrentStack<List<(Message Message, CoarseStopwatch QueuedTime)>> WaitingRequestsListPool = new(); |
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.
Summary
Validation
dotnet build src\Orleans.Runtime\Orleans.Runtime.csproj --nologo --verbosity minimal -property:UseSharedCompilation=falsedotnet build test\Grains\TestVersionGrains\TestVersionGrains.csproj --nologo --verbosity minimal -property:UseSharedCompilation=falsedotnet build test\Grains\TestVersionGrains2\TestVersionGrains2.csproj --nologo --verbosity minimal -property:UseSharedCompilation=falsedotnet test test\Orleans.Runtime.Tests\Orleans.Runtime.Tests.csproj --no-build --nologo --verbosity minimal -property:UseSharedCompilation=falseMicrosoft Reviewers: Open in CodeFlow