Skip to content

Add settle window to DataLoader batch dispatch#10129

Merged
michaelstaib merged 3 commits into
mainfrom
mst/dataloader-batch-settle-window
Jul 21, 2026
Merged

Add settle window to DataLoader batch dispatch#10129
michaelstaib merged 3 commits into
mainfrom
mst/dataloader-batch-settle-window

Conversation

@michaelstaib

@michaelstaib michaelstaib commented Jul 21, 2026

Copy link
Copy Markdown
Member

Summary

Adds a configurable settle window to the BatchDispatcher so a batch only becomes eligible for dispatch once it has gone a minimum amount of time without receiving new items. This widens the aggregation window under concurrent load, so fewer, larger batches reach the DataLoader.

Closes #9793

Copilot AI review requested due to automatic review settings July 21, 2026 13:30

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 configurable settle window to BatchDispatcher so batches become dispatch-eligible only after a minimum quiet period, improving aggregation under concurrent load while preserving age-based forced dispatch semantics.

Changes:

  • Added BatchSettleTimeUs plus “was set” tracking to BatchDispatcherOptions so default(BatchDispatcherOptions) yields documented defaults.
  • Updated BatchDispatcher dispatch eligibility and coordinator loop to incorporate settle time and replace the prior idle-cycle heuristic with a time-based no-dispatch streak/backoff strategy.
  • Added/updated tests for settle window behavior and option default handling, plus an additional experiment-style test file.

Reviewed changes

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

Show a summary per file
File Description
src/HotChocolate/Core/src/Types/Fetching/BatchDispatcher.cs Adds settle-window gating to dispatch eligibility and revises coordinator backoff/evaluation signaling.
src/HotChocolate/Core/src/Types/Fetching/BatchDispatcherOptions.cs Adds BatchSettleTimeUs and explicit default handling for default(...) scenarios.
src/HotChocolate/Core/src/Types/Fetching/BatchDispatcher.IBatchScheduler.cs Removes now-unused enqueue timestamp tracking.
src/HotChocolate/Core/src/Types/Fetching/BatchDispatcher.ExecutorSession.cs Removes now-unused subscribe timestamp tracking.
src/HotChocolate/Core/test/Fetching.Tests/BatchDispatcherTests.cs Adds tests for settle window inclusion of late items and default/zero option semantics.
src/HotChocolate/Core/test/Execution.Tests/Integration/DataLoader/DataLoaderBatchAggregationExperimentTests.cs Adds measurement-only experiment tests for batch aggregation behavior under load.
Comments suppressed due to low confidence (2)

src/HotChocolate/Core/src/Types/Fetching/BatchDispatcherOptions.cs:19

  • The XML doc says "class" but BatchDispatcherOptions is a struct. Updating this avoids misleading generated docs.
    /// <summary>
    /// Initializes a new instance of the <see cref="BatchDispatcherOptions"/> class.
    /// </summary>

src/HotChocolate/Core/src/Types/Fetching/BatchDispatcher.cs:165

  • This comment implies we only return when in-flight dispatches are completed, but the code returns whenever openBatches == 0 (relying on dispatch completion continuations to re-signal the coordinator). Please update the comment to match the actual control flow.
            // If we have no open batches to evaluate and all in-flight dispatches
            // are completed, we can stop and wait for another signal.
            // If there are in-flight dispatches still running we also stop and
            // wait for their completion signal.
            if (openBatches == 0)

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/HotChocolate/Core/test/Fetching.Tests/BatchDispatcherTests.cs
Comment thread src/HotChocolate/Core/test/Fetching.Tests/BatchDispatcherTests.cs
@github-actions

Copy link
Copy Markdown
Contributor

Patch coverage

100.0% of changed lines covered (46/46)

File Covered Changed Patch %
src/HotChocolate/Core/src/Types/Fetching/BatchDispatcher.cs 27 27 100.0% 🟢
…/Core/src/Types/Fetching/BatchDispatcherOptions.cs 19 19 100.0% 🟢

Project coverage: 53.8% (231332/430063 lines)

The file was scaffolding for GitHub discussion #9793 and, per its own header,
was not meant to be committed. The tests assert nothing and always pass, so
they add CI runtime without providing regression coverage.
@michaelstaib
michaelstaib merged commit b24860e into main Jul 21, 2026
145 of 147 checks passed
@michaelstaib
michaelstaib deleted the mst/dataloader-batch-settle-window branch July 21, 2026 22:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants