feat(engine): plan-time schedule-tree scheduler + runtime dataflow executor#1535
Draft
jensneuse wants to merge 5 commits into
Draft
feat(engine): plan-time schedule-tree scheduler + runtime dataflow executor#1535jensneuse wants to merge 5 commits into
jensneuse wants to merge 5 commits into
Conversation
Contributor
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
Port of the fork's hot-path pre-sizing (818aaa2): single-slab result allocation in resolveParallel, HTTP request buffer pre-sizing, singleflight key buffer reuse, and resolvable field-path buffer pre-sizing. Verified at parity on the flags-off A/B benchmark gate. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…ScheduleTree) Ports the improve-query-order scheduler with two load-bearing deviations, both found by adversarial review against real planner output: 1. validateParallelLeaves trusts FetchID dependency edges ONLY. The upstream path-containment heuristics false-positive on the canonical federation plan (a fetch attaching under an ancestor-provided subtree is independent of a sibling merging into a prefix path; the planner emits explicit edges when a dependency is real) and panicked every affected request. 2. buildScheduleTreeProcessor never panics: any scheduler/validator error falls back to the legacy orderSequenceByDependencies+createParallelNodes pipeline, planning exactly as with the option off. Includes the property/scenario suites, a 13-fetch real-plan schedule pin, and the ADR. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…e trees Ports the improve-query-order loader protocol with three deviations, each pinned by a regression test: 1. resolveParallelWithCtx routes flat Parallels through the locked nested path whenever useMergeMu is set — upstream's bare shape check lets a flat Parallel inside a nested tree merge lock-free against locked sibling merges (verified data race; TestLoaderNestedTreeFlatParallelTakesLockedPath fails under -race if the gate is reverted, verified empirically). 2. shouldSkipErroredDependencyLocked is gated on useMergeMu so flat-plan error-path bytes stay identical to the legacy executor. 3. The pooled batch tools are registered for Put BEFORE the prepare-error return; upstream leaks the pooled arena on every failed batch prepare. Also documents the nested executor's completion-order sink-append property and its tree-order staging follow-up. Sink audit re-run against master: the three order-bearing sinks (resolvable.errors, ctx.subgraphErrors, resolvable.subgraphExtensions) are written only from merge-phase functions; resolvable.go's growth since v2.4.1 added no new writers; executeSourceLoad remains arena-free. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…r-owned arena Replaces the per-wave barrier with per-FetchID dependency gating for flat query plans (default off; ResolverOptions.EnableDataflowExecution). Each fetch's network load starts when its OWN dependencies have merged, which collapses wall-clock latency to the dependency-graph critical path under skewed subgraph latency (measured -37% on the gateways-benchmark workload). Correctness by construction, with nine falsifiable invariants documented in the file header: every arena access runs on the coordinator goroutine (workers execute only the arena-free source load); the three audited error sinks are swap-captured per leaf and replayed in leaf order, making error/extension output byte-identical to the wave executor; dispatch pops the global leaf-index minimum so pre-fetch hook order matches wave spawn order whenever the DAG permits; nested (schedule-tree) plans are structurally rejected and fall back to the wave executor. Both dispatch-order falsification checks verified on this base: FIFO pop and FetchID-order pop each make TestDataflowPreFetchHookOrder fail. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
c3d7be0 to
f75f280
Compare
jensneuse
added a commit
to wundergraph/cosmo
that referenced
this pull request
Jun 11, 2026
Pins both router modules to github.com/wundergraph/graphql-go-tools/v2@v2.4.6-0.20260611164326-f75f280f48dd (wundergraph/graphql-go-tools#1535: schedule-tree scheduler + dataflow executor, rebased on v2.4.5/go-arena v1.3.0). To be moved to a tagged release once that PR merges. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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 join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
feat(engine): plan-time schedule-tree scheduler + runtime dataflow executor
Two independent, default-off engine execution improvements that collapse
federated query latency to the dependency-graph critical path under skewed
subgraph latency, plus hot-path allocation reductions.
Measured on the gateways-benchmark workload (one slow subgraph):
−37% median latency for either feature vs the shipping wave executor.
What's in here (4 commits)
perf(resolve): pre-size buffers and slab-allocate parallel fetch results
Single-slab result allocation in
resolveParallel, HTTP request bufferpre-sizing, singleflight key buffer reuse, resolvable field-path buffer
pre-sizing. Verified at parity on a flags-off A/B (+1.2%, within noise).
feat(postprocess): dominance-based schedule-tree scheduler (
WithBuildScheduleTree)Ports the
improve-query-orderscheduler with two load-bearing fixes foundby adversarial review against real planner output:
validateParallelLeavestrusts FetchID dependency edges ONLY. Thepath-containment heuristics false-positive on the canonical federation
plan (a fetch attaching under an ancestor-provided subtree is independent
of a sibling merging into a prefix path — the planner emits explicit
edges when a dependency is real, e.g.
deps [1,2]on the fetch thatactually reads sibling data) and panicked every affected request.
buildScheduleTreeProcessornever panics: any scheduler/validator errorfalls back to the legacy
orderSequenceByDependencies+createParallelNodespipeline, planning exactly as with the option off.Includes the property/scenario suites, a 13-fetch real-plan schedule pin
(
TestBuildScheduleTreeRealGatewaysBenchmarkPlan), and the ADR.feat(resolve): 3-phase prepare/load/merge protocol for nested schedule trees
The executor support for nested plans, with three deviations, each pinned
by a regression test that fails if the deviation is reverted:
(
useMergeMu ||gate) — fixes a verified data race;useMergeMu— flat-plan error-pathbytes stay identical to the legacy executor;
PutBEFORE the prepare-error return —fixes a pooled-arena leak on failed batch prepares.
feat(resolve): dataflow executor (
ResolverOptions.EnableDataflowExecution)Per-FetchID dependency gating for flat query plans: each fetch's network
load starts when its OWN dependencies have merged. Nine falsifiable
invariants documented in the file header; the load-bearing ones:
only the arena-free source load) — no mutex, race-free by construction;
leaf order — error/extension output is byte-identical to the wave
executor;
(authorizer/rate-limiter) matches wave spawn order whenever the DAG
permits;
the two features compose safely.
Default-off guarantee
With both options off, behavior is byte-identical and at performance parity:
-racesuites for resolve/postprocess/graphql_datasource pass withzero exclusions, including
-count=50stress on the byte-identity and racestress tests.
Known properties (documented in code)
parallel branches (error-path only; tree-order sink staging is the named
follow-up, and the dataflow executor already implements that staging).
(invalid federation data) follows completion order.
Review provenance
The implementation survived three adversarial codex review cycles to
GATE-CLEAN during development plus a final whole-branch review (GATE-CLEAN);
every P1 found along the way is fixed and pinned by an empirically falsified
regression test.
🤖 Generated with Claude Code