graphql-go-tools
graphql-go-tools copied to clipboard
The EngineV2Configuration function is very slow for large schema
Our service schemas are 1k-4k lines each, and producing an engine configuration for all services (around 35k lines total) takes about 15-20 seconds on a 2.7 GHz Quad-Core Intel Core i7.
The bottleneck appears to be the baseSchema
method on LocalTypeFieldExtractor
which prints and parses the schemas multiple times for each type. Engine construction time is important to us because we construct multiple engines and replace engines as schemas updated.
#293 is also related to the federation config factory. It could make sense to address both issues at the same time since node traversal needs to be updated for #293.
Would you be up for us optimizing construction of the engine config?
I'm open to a PR. Ideally, you can add a benchmark as well to prove the improvement? We are also very strict about testing so make sure your PR is well tested. Additionally, you file small PRs that address a single issue. This makes it easier to review and merge. I'm always afraid of big PRs which touch everything. Then it takes longer to merge. That said, I would really appreciate your contribution!
Great. Yes, that all makes sense and sounds good. I'll make sure PRs are targeted and well tested. And yes, I can also add a benchmark to show the improvement 👍.
@dnerdy How long does it take with your updated branch with the improvements? Is the processing time now acceptable?
Yes! Constructing an engine configuration now takes around 60ms for our schema instead of 15-20 seconds, which is great.