Skip to content

perf(scheduler): use activation-specific work signal#10116

Draft
ReubenBond wants to merge 1 commit into
dotnet:mainfrom
ReubenBond:rebond/activation-scheduler-signal-memory
Draft

perf(scheduler): use activation-specific work signal#10116
ReubenBond wants to merge 1 commit into
dotnet:mainfrom
ReubenBond:rebond/activation-scheduler-signal-memory

Conversation

@ReubenBond

@ReubenBond ReubenBond commented May 17, 2026

Copy link
Copy Markdown
Member

Summary

  • Add an activation-specific auto-reset event with a smaller custom value-task source.
  • Schedule activation message-loop continuations through the activation WorkItemGroup without taking the broad scheduler refactor.
  • Add coverage for signal ordering, reuse, concurrent waiter rejection, scheduler continuation affinity, and signal/awaiter races.

Validation

  • dotnet build src\Orleans.Runtime\Orleans.Runtime.csproj --no-restore --nologo --verbosity minimal -property:UseSharedCompilation=false
  • dotnet test test\Orleans.Core.Tests\Orleans.Core.Tests.csproj --no-restore --nologo --verbosity minimal --filter FullyQualifiedName~ActivationAutoResetEventTests -property:UseSharedCompilation=false
Microsoft Reviewers: Open in CodeFlow

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

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 introduces a new activation-scoped auto-reset signaling primitive to wake an activation’s message loop and ensure continuations are scheduled via the activation’s WorkItemGroup (scheduler-affine), along with targeted unit test coverage.

Changes:

  • Added ActivationAutoResetEvent, a single-waiter, concurrent-signalers auto-reset event which queues continuations through a provided WorkItemGroup.
  • Updated ActivationData to use the new activation-specific work signal instead of SingleWaiterAutoResetEvent.
  • Added ActivationAutoResetEventTests covering ordering, reuse, concurrent waiter rejection, scheduler-affine continuations, and wait/signal races.
Show a summary per file
File Description
test/Orleans.Core.Tests/SchedulerTests/ActivationAutoResetEventTests.cs Adds unit tests validating the new activation-scoped auto-reset event semantics and scheduler affinity.
src/Orleans.Runtime/Versions/ActivationAutoResetEvent.cs Introduces the new scheduler-affine auto-reset event backed by a custom IValueTaskSource.
src/Orleans.Runtime/Catalog/ActivationData.cs Switches the activation message loop wake-up signal to ActivationAutoResetEvent tied to the activation WorkItemGroup.

Copilot's findings

  • Files reviewed: 3/3 changed files
  • Comments generated: 1

Comment on lines +131 to +153
public void OnCompleted(Action<object?> continuation, object? state, short token, ValueTaskSourceOnCompletedFlags flags)
{
ArgumentNullException.ThrowIfNull(continuation);
ValidateToken(token);

object? storedContinuation = _continuation;
if (storedContinuation is null)
{
_continuationState = state;
storedContinuation = Interlocked.CompareExchange(ref _continuation, continuation, null);
if (storedContinuation is null)
{
return;
}
}

if (!ReferenceEquals(storedContinuation, Sentinel))
{
ThrowInvalidOperationException();
}

QueueContinuation(continuation, state);
}
@ReubenBond ReubenBond changed the title Use activation-specific work signal perf(scheduler): use activation-specific work signal May 29, 2026
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