Repository navigation
perf(execution): reduce field overhead - faster introspection - #299
Merged
Merged
Conversation
Skip coercion when the field and query node have no arguments. Pass async error-handler state as parameters to avoid closure cells in ordinary field execution. Co-Authored-By: Aiden <aiden@weco.ai>
Merging this PR will improve performance by 18.7%1 warning
Performance Changes
Tip Curious why performance improved? Comment Comparing |
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.
TL;DR
execute_fieldoverhead during synchronous query execution.PYTHONPATH=src python -m pytest tests -q: 3,613 passed, 18 skipped.Refs #298
What & Why
Each field currently calls argument coercion, even when the field and query have no arguments.
An inner async function also captures local values, which adds work to synchronous calls.
Use an empty dictionary directly when both argument collections are empty.
Give the async function explicit parameters so ordinary field execution does not need those captured values.
Results
These are median times from at least 50 rounds on CPython 3.12.13, Linux x86-64, and an AMD EPYC 9R14.
Both versions ran sequentially on the same CPU.
The async-list and pickle-decoding slowdowns are smaller than the larger interquartile spread from their respective runs.
The async benchmark resolves one field and spends most of its time processing list items.
Pickle decoding does not call the changed method.
Validation
Run on the base commit and this change:
Ruff, formatting, and mypy passed for all 355 source and test files.
Why this is safe and easy to maintain
The patch changes one method and adds no helpers or dependencies.
Resolver arguments, completion, returned values, and error handling stay unchanged.
Existing execution tests cover resolver information, subclass hooks, middleware, argument defaults, and nullable errors.
Scope
This changes Python execution overhead without adding features or changing public signatures.
It keeps the existing GraphQL execution rules and resolver-information constructor.
AI assistance
Codex gpt-6.1-sol generated candidates tracked with Weco Observe.
Codex also helped run automated checks and prepare this description.
Weco share link: https://dashboard.weco.ai/share/NKlrkTVvI9HA-J73ZOdnjmMXw0g4xOYq