Repository navigation
perf(durable-jobs): reduce queue wake-ups - #11103
Merged
ReubenBond merged 1 commit intoSep 5, 2026
Merged
Conversation
Contributor
There was a problem hiding this comment.
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>
ReubenBond
force-pushed
the
rb-perf-durable-jobs-reduce-queue-wakeups
branch
from
September 4, 2026 22:50
593dfcc to
ca8daab
Compare
This was referenced Oct 3, 2026
Closed
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.
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