graphql-go-tools icon indicating copy to clipboard operation
graphql-go-tools copied to clipboard

The EngineV2Configuration function is very slow for large schema

Open dnerdy opened this issue 3 years ago • 4 comments

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?

dnerdy avatar Oct 22 '21 02:10 dnerdy

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!

jensneuse avatar Oct 22 '21 05:10 jensneuse

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 avatar Oct 22 '21 17:10 dnerdy

@dnerdy How long does it take with your updated branch with the improvements? Is the processing time now acceptable?

jensneuse avatar Nov 08 '21 16:11 jensneuse

Yes! Constructing an engine configuration now takes around 60ms for our schema instead of 15-20 seconds, which is great.

dnerdy avatar Nov 09 '21 03:11 dnerdy