Skip to content

Fix activation-count placement fallback for partial statistics#9914

Merged
ReubenBond merged 5 commits into
dotnet:mainfrom
ReubenBond:fix/LoadAwareGrainShouldNotAttemptToCreateActivationsOnOverloadedSilo
Feb 13, 2026
Merged

Fix activation-count placement fallback for partial statistics#9914
ReubenBond merged 5 commits into
dotnet:mainfrom
ReubenBond:fix/LoadAwareGrainShouldNotAttemptToCreateActivationsOnOverloadedSilo

Conversation

@ReubenBond

@ReubenBond ReubenBond commented Feb 13, 2026

Copy link
Copy Markdown
Member

Summary

  • avoid per-placement HashSet allocation in ActivationCountPlacementDirector
  • use direct random compatible-silo fallback when no compatible silo stats are available
  • preserve overload rejection when all compatible silos are known and overloaded

Validation

  • dotnet test .\\test\\TesterInternal\\TesterInternal.csproj --filter "FullyQualifiedName~UnitTests.General.ElasticPlacementTests.LoadAwareGrainShouldNotAttemptToCreateActivationsOnOverloadedSilo" --nologo --verbosity minimal
  • repeated flaky-case validation: 5x --no-build runs of the same test
Microsoft Reviewers: Open in CodeFlow

Copilot AI review requested due to automatic review settings February 13, 2026 05:22

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

This PR improves the activation count-based placement strategy by optimizing performance and fixing edge cases in fallback logic when silo statistics are partially available.

Changes:

  • Removed per-placement HashSet allocation by eliminating the ToSet() call on compatible silos
  • Implemented reservoir sampling for uniform random selection when silos lack statistics
  • Changed empty-cache fallback from local silo to random compatible silo placement

Comment thread src/Orleans.Runtime/Placement/ActivationCountPlacementDirector.cs Outdated

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

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

Comments suppressed due to low confidence (1)

src/Orleans.Runtime/Placement/ActivationCountPlacementDirector.cs:112

  • The error message mentions "from {silos.Length} compatible silos" but then enumerates all silos from _localCache (which includes incompatible silos). This could be confusing when debugging. Consider either:
  1. Filtering the enumeration to only show compatible silos: Utils.EnumerableToString(silos.Select(s => KeyValuePair.Create(s, _localCache.GetValueOrDefault(s))), ...)
  2. Clarifying the message: "Unable to select a candidate from {silos.Length} compatible silos (all are overloaded). All silo stats: {Utils.EnumerableToString(all, ...)}"
            throw new SiloUnavailableException($"Unable to select a candidate from {silos.Length} compatible silos: {Utils.EnumerableToString(all, kvp => $"SiloAddress = {kvp.Key} -> {kvp.Value}")}");

Comment thread test/NonSilo.Tests/Runtime/ActivationCountPlacementDirectorTests.cs
Comment thread src/Orleans.Runtime/Placement/ActivationCountPlacementDirector.cs Outdated
Comment thread src/Orleans.Runtime/Placement/ActivationCountPlacementDirector.cs Outdated
@ReubenBond ReubenBond added this pull request to the merge queue Feb 13, 2026
Merged via the queue into dotnet:main with commit df20c21 Feb 13, 2026
59 checks passed
@ReubenBond ReubenBond deleted the fix/LoadAwareGrainShouldNotAttemptToCreateActivationsOnOverloadedSilo branch February 13, 2026 23:57
rkargMsft pushed a commit to rkargMsft/orleans that referenced this pull request Feb 27, 2026
…t#9914)

* Fix activation-count placement fallback with partial stats

* Restore local fallback when placement stats cache is empty

* Simplify activation-count fallback control flow

* Fix activation-count placement local compatibility

* Address PR review feedback
@github-actions github-actions Bot locked and limited conversation to collaborators Mar 16, 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