Closed yassinebridi closed 3 years ago
How many files is generated in 4 mins? In example project I got 387 files in 10s, which is 10000/387 ~ 26 ms per file. Writing file on disk is expensive i/o operation.
I will measure generation time without saving on disk.
In general, I dont think that there is a lot of room for improvememt in generating clean project. But there are some when doing rebuild (incremental build, etc.)
Do you aware of TypeGraphQL for prisma, do you know how much time takes generation for them?
My suggestion was wrong, generation before saving files takes ~ 8.6s.
But still, I dont think that speed can be improved significantly because it's built on the top of other tools.
I just ran some metrics(with 899 generated files):
prisma-client
: 12sec
typegraphql-prisma
: 43sec
prisma-nestjs-graphql
: 02m:28s
prisma-nestjs-graphql
(with reExportAll
) : 03m:43sec
This is relative of course to each machine. Still deployment servers(especially limited ones) can't handle how much resources being taken to generate using prisma-nestjs-graphql
This is how i'm using prisma-nestjs-graphql
in my prisma.schema
generator nestgraphql {
provider = "node ../../node_modules/.bin/prisma-nestjs-graphql"
output = "./@generated"
}
This is the context of yarn workspaces
, i don't know to how much extent this affect things.
Wow. That is big difference even with typegraphql, which generates same or more files.
I am seeing 3 minute build times on @9 as well which has jumped to 10 minutes on @10
10 also seems to have broken a couple of things and is emitting empty files. I will submit an issue around that.
I've made some improvements advised by https://ts-morph.com/manipulation/performance
You can try install beta version from next channel npm install -D prisma-nestjs-graphql@next
Speed should increase approximately by 3 times.
But with option reExportAll
it's still slow.
Our 3 minute and 10 minute build times are down to 39 seconds ... so it's a significant improvement.
I will run some metrics on my part again, and i will get back to you.
There was a huge difference with the latest changes, here is what i found:
prisma client
: 12sec
typegraphql-prisma
: 40sec
prisma-nestjs-graphql
(with reExportAll): 01m:14s(This is still a huge drop too)
prisma-nestjs-graphql
(without reExportAll): 14s 🤯
It's almost the same timing as with prisma client alone.
If reExportAll
could do the same timing as without it, that would be pretty neat.
For now i think i will refactor my code to use without reExportAll
.
I really appreciate these changes @unlight, thank you.
The project i'm working on, is fairly big, so i have so many models, and relationships. The generation process produced by this generator takes quite a lot of time(roughly 4 min). While the generation of prisma client takes almost no time(5s).
I'm not sure how prisma client generation works, or what they are doing differently, if they use their rust package to generate, or the fact that they are dumping all generated classes on one file, instead of multiple files and folders, like this generator does. But the time difference between the two is huge.
The big problem actually relies on how much ram the generation process takes, that it kills my docker instance before generating anything. So for now, i only generate and build my project locally.