Skip to content

perf(durable-jobs): reduce queue wake-ups - #11103

Merged
ReubenBond merged 1 commit into
dotnet:mainfrom
ReubenBond:rb-perf-durable-jobs-reduce-queue-wakeups
Sep 5, 2026
Merged

ReubenBond merged 1 commit into
dotnet:mainfrom
ReubenBond:rb-perf-durable-jobs-reduce-queue-wakeups

Conversation

@ReubenBond

@ReubenBond ReubenBond commented Sep 4, 2026 •

Copy link
Copy Markdown
Member

Problem

Queue mutations wake the durable job queue enumerator even when its currently observed next due time is unchanged. This creates avoidable wake-ups and timer recreation under queue activity.

Solution

Track the queue-change waiter lazily and signal it only when a mutation changes the next observable due time. Preserve completion by also signaling when removal of the final already-dequeued job empties a completed queue.

Rationale

The enumerator only needs to reconsider its wait when the queue head changes or completion becomes observable. Keeping waiter creation and signaling aligned with those transitions reduces scheduling churn without losing wake-ups.

Microsoft Reviewers: Open in CodeFlow

Copilot AI lite review requested due to automatic review settings September 4, 2026 22:17

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.

Copilot review overview

🟢 Approval recommended

The change is scoped, preserves correctness for enumeration and completion, and is backed by targeted regression tests for the new signaling conditions.

Review tier: Lite
Findings: None

What changed in this PR

This PR optimizes InMemoryJobQueue (durable jobs) by reducing unnecessary enumerator wake-ups/timer churn when queue mutations don’t affect the next observable due time, while preserving correct completion signaling.

Changes:

  • Lazily create and retain the “queue changed” waiter only when an enumerator is actually waiting.
  • Signal the enumerator only when the next due time changes, or when completion becomes newly observable (completed + no remaining tracked jobs).
  • Add tests covering wake-up behavior when retrying a job earlier and when removing the final dequeued job after completion.
File Description
src/​Orleans.DurableJobs/​InMemoryJobQueue.cs Lazily manages the queue-change waiter and conditionally signals based on next-due-time/completion observability.
test/​Orleans.Core.Tests/​DurableJobs/​InMemoryJobQueueTests.cs Adds regression tests for the new wake-up conditions (retry earlier, completion after last dequeued removal).

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Co-authored-by: ksemenenko <mail@ksemenenko.com>
Copilot AI review requested due to automatic review settings September 4, 2026 22:50
@ReubenBond
ReubenBond force-pushed the rb-perf-durable-jobs-reduce-queue-wakeups branch from 593dfcc to ca8daab Compare September 4, 2026 22:50

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.

Copilot review overview

🟢 Approval recommended

The change is narrowly scoped, preserves enumerator correctness, and is backed by new tests covering the key wake-up and completion scenarios.

Review tier: Lite
Findings: None

@ReubenBond
ReubenBond merged commit 1670ccc into dotnet:main Sep 5, 2026
77 checks passed
@ReubenBond
ReubenBond deleted the rb-perf-durable-jobs-reduce-queue-wakeups branch September 5, 2026 14:06
@github-actions github-actions Bot locked and limited conversation to collaborators Oct 6, 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