Repository navigation
Poll async fields and list items once in place - #1418
Merged
Merged
Conversation
Asynchronous execution pushed every field and every list item into a `FuturesOrdered` set. Each push allocated a task, and each poll paid for atomic waker operations. Most futures complete on their first poll, so this cost bought nothing. The future of `GraphQLValueAsync::resolve_field_async()` borrowed its arguments and its executor, so the executor kept them in an outer future of its own. The executor also added a `__typename` field to the object before the pending fields, so `__typename` could appear out of order. `resolve_field_async()` and the generated `AsyncField::call()` take the `Arguments` and the `Executor` by value, so the resolver future owns them. `Executor` is now `Copy`, because all its fields are shared references or `Copy` values. The generated resolver extracts its arguments inside its future. The executor polls the future of a field or a list item once when it creates the future. A completed field merges into the object, or waits in a queue behind a pending field. A `__typename` field takes its place in the queue too. Only pending futures go to a `FuturesUnordered` set, and the queue keeps the order of the fields and items. A `null` item of a non-`null` list stops the resolution of the remaining items, as in synchronous execution. One function now completes field results for both synchronous and asynchronous execution. Asynchronous execution of a flat list of 1000 objects now makes 19,067 allocations instead of 27,069. On the benchmark operations except introspection, asynchronous execution takes 6 to 39% less time. Synchronous execution and introspection do not change. New tests check the order of fields around a pending field, the order of pending and ready list items, and the `null` list from a failing ready item and a failing pending item. The manual implementations in the tests use the new signature.
LegNeato
force-pushed
the
async-polling
branch
from
November 9, 2026 04:45
b6f231d to
4a43e14
Compare
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 PR builds on #1417. Only its last commit is new.
FuturesUnorderedset. Every field and every list item used to go to aFuturesOrderedset, and each push allocated a task.__typenamefield after a pending field.resolve_field_async()and the generatedAsyncField::call()take theArgumentsand theExecutorby value, so the resolver future owns them. The executor used to keep them in an outer future of its own.Executoris nowCopy.On the benchmarks of #1413 except introspection, asynchronous execution takes 6 to 39% less time than with #1417. Synchronous execution and introspection do not change. An asynchronous execution of 1000 objects with 6 fields each makes 19,067 allocations instead of 27,069.