graphqlgen
graphqlgen copied to clipboard
Speed up generation
I thought I'd open this PR for discussion.
Currently, running graphqlgen
on a project with a large schema is very slow. For example, running graphqlgen
on my project with a ~20,000 line schema takes over 2 minutes to complete.
I decided to do some quick profiling to figure out what was taking so long. To do this, I forked and cloned this repo, and then:
- In
packages/graphqlgen
, runyarn build
- cd into my project and run
node --inspect PATH_TO_GRAPHQLGEN_DIST_INDEX_JS
Here's the result:
To my surprise, formatting the code in generateTypes
was taking the vast majority of the time.
So, I decided to try disabling formatting the code in generateTypes
. Here's the result after applying the diff and following the same steps from above:
This took ~4500 ms instead of ~160,000 ms, a vast improvement.
However, I doubt most projects have this large of a schema, and a formatted graphqlgen.ts
is undeniably nicer to look at. Thoughts?
.zip of the .cpuprofile
s: Archive.zip
@apalm thanks for this!
- In #372 we introduced a benchmark system
- It would be great to add a currently-poorly-performing schema (+requisite models) to benchmarks, currently we're missing that
- Can you share yours?
What I'm thinking next steps can be:
- update and commit benchmarks with an awful case such as yours
- follow up on your findings in this PR and see if we can drastically drop that number without losing the formatting