strawberry icon indicating copy to clipboard operation
strawberry copied to clipboard

Improve resolving performance by avoiding extra calls for simple fields

Open jkimbo opened this issue 3 years ago • 8 comments
trafficstars

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: CleanShot 2022-09-22 at 15 32 43@2x

After: CleanShot 2022-09-22 at 15 32 23@2x

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).

jkimbo avatar Sep 22 '22 15:09 jkimbo

Codecov Report

Merging #2194 (75b1a45) into main (76cf1d5) will increase coverage by 0.00%. The diff coverage is 100.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            

codecov[bot] avatar Sep 22 '22 15:09 codecov[bot]

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)

botberry avatar Sep 22 '22 15:09 botberry

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 avatar Sep 22 '22 15:09 patrick91

/pre-release

patrick91 avatar Sep 22 '22 15:09 patrick91

Pre-release

:wave:

Releasing commit [0dae103c0b6ffa9b9f60ece70290e24d57bab179] to PyPi as pre-release! :package:

botberry avatar Sep 22 '22 15:09 botberry

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

botberry avatar Sep 22 '22 15:09 botberry

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

jkimbo avatar Sep 22 '22 15:09 jkimbo

Alex doesn't seem to like simple. I could change it to basic?

jkimbo avatar Sep 22 '22 16:09 jkimbo