strawberry
strawberry copied to clipboard
Improve resolving performance by avoiding extra calls for simple fields
Description
This change improves performance of resolving a query by skipping Info creation and permission checking for fields that don't have a resolver or permission classes. In local benchmarks it improves performance of large results by ~14%.
Before:

After:

Benchmarked on a Macbook M1 Air.
Types of Changes
- [x] Core
- [ ] Bugfix
- [ ] New feature
- [ ] Enhancement/optimization
- [ ] Documentation
Issues Fixed or Closed by This PR
Checklist
- [x] My code follows the code style of this project.
- [x] My change requires a change to the documentation.
- [ ] I have updated the documentation accordingly.
- [ ] I have read the CONTRIBUTING document.
- [ ] I have added tests to cover my changes.
- [x] I have tested the changes and verified that they work and don't break anything (as well as I can manage).
Codecov Report
Merging #2194 (75b1a45) into main (76cf1d5) will increase coverage by
0.00%. The diff coverage is100.00%.
Additional details and impacted files
@@ Coverage Diff @@
## main #2194 +/- ##
========================================
Coverage 98.19% 98.20%
========================================
Files 162 162
Lines 6492 6502 +10
Branches 1236 1449 +213
========================================
+ Hits 6375 6385 +10
Misses 58 58
Partials 59 59
Thanks for adding the RELEASE.md file!

Here's a preview of the changelog:
Improve resolving performance by avoiding extra calls for basic fields.
This change improves performance of resolving a query by skipping Info
creation and permission checking for fields that don't have a resolver
or permission classes. In local benchmarks it improves performance of large
results by ~14%.
Here's the preview release card for twitter:

Here's the tweet text:
🆕 Release (next) is out! Thanks to Jonathan Kim for the PR 👏
Get it here 👉 https://github.com/strawberry-graphql/strawberry/releases/tag/(next)
thanks for this! do you have an example of the code you used for the benchmarking? I'll add it here: https://github.com/strawberry-graphql/benchmarks
/pre-release
Pre-release
:wave:
Releasing commit [0dae103c0b6ffa9b9f60ece70290e24d57bab179] to PyPi as pre-release! :package:
Pre-release
:wave:
Pre-release 0.131.2.dev.1663861889 [0dae103c0b6ffa9b9f60ece70290e24d57bab179] has been released on PyPi! :rocket: You can try it by doing:
poetry add strawberry-graphql==0.131.2.dev.1663861889
thanks for this! do you have an example of the code you used for the benchmarking? I'll add it here: https://github.com/strawberry-graphql/benchmarks
@patrick91 its the benchmarking code in the repo already: https://github.com/strawberry-graphql/strawberry/tree/main/tests/benchmarks
Alex doesn't seem to like simple. I could change it to basic?