Re-align incremental delivery with the WorkQueue architecture#275
Merged
Conversation
First part of adopting the WorkQueue-based incremental delivery architecture, re-expressed with asyncio instead of Promise machinery; awaitable results are scheduled as cancellable futures. Replicates graphql/graphql-js@8e01e23
Second part of adopting the WorkQueue-based incremental delivery architecture; the graph event channel is a plain asyncio queue drained in batches, streams are pumped by cancellable tasks paced via a handled event, and cancellation awaits asynchronous cleanup. Replicates graphql/graphql-js@8e01e23
The architecture and control logic follow the upstream engine 1:1, re-expressed with native asyncio primitives instead of the JS promise machinery, while keeping the established GraphQL-core API surface. Replicates graphql/graphql-js@8e01e23, graphql/graphql-js@e89ca8c, graphql/graphql-js@9190a9f, graphql/graphql-js@229c9df, graphql/graphql-js@d7e040e, graphql/graphql-js@37a6299, graphql/graphql-js@3dd146d, graphql/graphql-js@85e545c
The changes to the legacy stream tests are not ported, since the legacy incremental format is not supported by GraphQL-core. Replicates graphql/graphql-js@fa06509
A streamed list field without a subselection that merge-conflicts with an unstreamed selection of the same field inside a sibling defer used to hang incremental delivery whenever another field of that sibling resolved later than the streamed field (issue #272). The WorkQueue architecture already fixes this; the test guards termination and asserts the delivered payloads.
Merging this PR will improve performance by 17.67%
|
| Benchmark | BASE |
HEAD |
Efficiency | |
|---|---|---|---|---|
| ⚡ | test_execute_async_iterable_list_field |
9.8 ms | 8.4 ms | +17.67% |
Tip
Curious why this is faster? Comment @codspeedbot explain why this is faster on this PR, or directly use the CodSpeed MCP with your agent.
Comparing feat/incremental-workqueue (477529a) with main (adf2fc7)
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.
This replaces the incremental delivery engine with the WorkQueue-based architecture that graphql-js adopted after v17.0.0-rc.0 (ported up to v17.0.2). A new Computation abstraction and a WorkQueue scheduler drive deferred and streamed execution; the control logic follows the upstream engine 1:1, but is re-expressed with native asyncio primitives instead of the JS promise machinery; streams are pumped by cancellable tasks with back-pressure, and cancellation awaits asynchronous cleanup. The established public API surface is unchanged.
Besides restoring alignment with upstream, the new architecture makes the invalid-state bug class behind #271 structurally impossible and fixes the non-termination reported in #272 (a spec-invalid @defer/@stream query could previously hang forever); a regression test for the latter is included.