Repository navigation
perf(runtime): reduce activation collection sorting allocations - #10342
Merged
ReubenBond merged 1 commit intoAug 5, 2026
Merged
Conversation
Co-authored-by: Copilot App <[email protected]>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR optimizes Orleans runtime activation shedding by removing per-collection LINQ sorting allocations when ordering activation collection buckets by due time, replacing it with an in-place sort of the existing snapshot array.
Changes:
- Replace
bucketSnapshot.OrderBy(...)withArray.Sort(...)to sort the bucket snapshot in place during memory-pressure collection. - Update the related concurrency/race-condition test comment to reflect the new “snapshot then sort” behavior.
Show a summary per file
| File | Description |
|---|---|
src/Orleans.Runtime/Catalog/ActivationCollector.cs |
Sorts the bucket snapshot array in place to reduce allocations and improve activation shedding performance. |
test/Orleans.Core.Tests/Runtime/ActivationCollectorTests.cs |
Updates test commentary to match the snapshot-and-sort approach under concurrent add/remove activity. |
Copilot's findings
- Files reviewed: 2/2 changed files
- Comments generated: 0
This was referenced Aug 28, 2026
Merged
Merged
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Activation shedding snapshots and orders collection buckets by due time. Using LINQ
OrderByallocated an additional sort buffer and iterator objects on every memory-pressure collection pass.Sort the existing snapshot array in place instead. This preserves due-time ordering and concurrency safety while avoiding the extra allocations.
In a BenchmarkDotNet comparison with 500 buckets, the in-place sort reduced mean time from 33.87 us to 27.20 us (20% faster) and allocations from 21.79 KB to 7.84 KB (64% lower).
Microsoft Reviewers: Open in CodeFlow