apollo-tooling: [Swift] Huge performance regression
Going from 2.17.4 to 2.18.3. Codegen time ballooned from 40s to 240s.
codegen:generate --includes='./**/*.graphql' --localSchemaFile="schema.json" --passthroughCustomScalars --target=swift Sources/Core/Generated/
How to reproduce the issue:
To help understand the size of this project: 87 .graphql files schema is 136,639 lines Sources/Core/Generated/ is 2.2MB
Versions
2.18.3
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 1
- Comments: 22 (21 by maintainers)
@jbaxleyiii Tested your branch on my project and performance improved significantly. Not sure how I got the 40s number before, but on 2.17.4 I’m seeing ~21s after several runs and ~23s with your branch.
After looking at this a bit, it appears that for every single field it re-visits the entire AST just to find out if that field is inside a client directive.
A much more sane way to do this is to visit the entire AST once, and annotate the nodes that are in client directives (if we can’t modify the nodes directly, perhaps we can stuff them in a lookup table that we can check in O(1) instead).
I upgraded from 2.18.3 to 2.19.1 and I went from ~140 second to ~2 seconds on around 180 queries. 😄
Good job.
Working on a release for this now, I’ll update with a version once it’s out