Skip to content

feat(runtime): add activation keep-alive holds - #11506

Merged
ReubenBond merged 2 commits into
dotnet:mainfrom
ReubenBond:rb-activation-keepalive-holds
Oct 15, 2026
Merged

ReubenBond merged 2 commits into
dotnet:mainfrom
ReubenBond:rb-activation-keepalive-holds

Conversation

@ReubenBond

@ReubenBond ReubenBond commented Oct 14, 2026 •

Copy link
Copy Markdown
Member

Problem

Runtime components that perform background work on behalf of an activation — for example, the durable messaging pump servicing queued work and in-flight outbox deliveries — need to keep that activation from being idle-collected while the work is pending. Per-message keep-alive and DelayDeactivation model neither "held while X is in flight" nor multiple independent holders.

Solution

  • Adds the internal IActivationKeepAlive interface (AcquireKeepAlive / ReleaseKeepAlive), implemented by ActivationData.
  • Holds are counted in an int field on the lazily allocated ActivationDataExtra.
  • Idle collection respects holds: TryDeactivateForCollection with respectKeepAlive, and the working-set IsCandidateForRemoval check. Memory-pressure collection and explicit deactivation proceed regardless of holds.
  • Releasing the last hold on a valid activation restarts its idle period through a new MarkActive helper, which OnCompletedRequest now shares. A deactivating or disposed activation stays out of the working set.
  • Adds ActivationCollectorTests coverage. One test checks that counted holds keep an activation alive and that it is collected after release. Another releases the final hold outside request processing after the original idle period expired, and checks that collection waits for a fresh idle period.

Rationale

ActivationData gains no new fields; only activations which take holds allocate the extras. The API is internal, so there is no public API surface change. This was split out of #11505 (RunRequestAsync), and its first consumer is the durable messaging pump in #11282.

Microsoft Reviewers: Open in CodeFlow

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.

🟡 Changes recommended

Final release can reinsert a disposed activation into the working set, and independent idle-reset regression coverage is missing.

2 open findings
What changed in this PR

Adds internal, counted activation keep-alive holds for background work, preparing the runtime for durable messaging.

Changes:

  • Makes idle collection respect holds while allowing explicit and memory-pressure deactivation.
  • Restarts idleness on final release using shared activity bookkeeping.
  • Adds collection tests and supporting grain methods.

Automated coverage results were unavailable.

File Description
test/​Orleans.Runtime.Internal.Tests/​ActivationsLifeCycleTests/​ActivationCollectorTests.cs Tests collection with multiple holds.
test/​Grains/​TestInternalGrains/​ActivationGCTestGrains.cs Implements test hold operations.
test/​Grains/​TestInternalGrainInterfaces/​ActivationGCTestGrainInterfaces.cs Exposes test hold operations.
src/​Orleans.Runtime/​Catalog/​ActivationData.cs Implements holds and collection integration.
src/​Orleans.Core/​Runtime/​IActivationKeepAlive.cs Defines the internal hold contract.

🧠 Review effort: Balanced


💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Copilot AI balanced review requested due to automatic review settings October 14, 2026 22:04

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.

🟢 Approval recommended

Static review supports the hold accounting, lifecycle guards, and regression coverage, with no unresolved blocking issues.

0 open findings

2 resolved since last review

🧠 Review effort: Balanced

@github-actions

github-actions Bot commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

Code coverage

Metric Pull request Current main Variance
Lines 83.46% (118,620 / 142,124) 83.49% (118,643 / 142,103) -0.0285 pp
Branches 73.04% (35,297 / 48,326) 73.07% (35,299 / 48,308) -0.0314 pp

Report-only conclusion: regressed.

The current-main baseline is commit 4d94a394bc and uses the same reviewed coverage matrix.

Coverage combines every CI test matrix job, including providers, CodeGen, .NET 8/10, Linux, Windows, and macOS, using canonical physical source and branch identities.

The comparison remains report-only while normal line and branch variance is calibrated.

Coverage details

@ReubenBond
ReubenBond merged commit 68e5f18 into dotnet:main Oct 15, 2026
94 checks passed
@ReubenBond
ReubenBond deleted the rb-activation-keepalive-holds branch October 15, 2026 13:51
@github-actions github-actions Bot locked and limited conversation to collaborators Nov 15, 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