Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prisma 4.3.0 takes 100x more time to generate types #15109

Closed
annibuliful opened this issue Aug 31, 2022 · 18 comments · Fixed by #15122
Closed

Prisma 4.3.0 takes 100x more time to generate types #15109

annibuliful opened this issue Aug 31, 2022 · 18 comments · Fixed by #15122
Assignees
Labels
bug/2-confirmed Bug has been reproduced and confirmed. kind/regression A reported bug in functionality that used to work before. team/client Issue for team Client. topic: prisma generate CLI: prisma generate topic: type performance
Milestone

Comments

@annibuliful
Copy link

annibuliful commented Aug 31, 2022

Bug description

V. 4.3.0
187598994-598fb1a8-ab77-4328-8cad-d986b8f75804

V.4.2.1
Screen Shot 2565-08-31 at 12 27 22

How to reproduce

  • Generate Prisma type

Expected behavior

  • Generate Prisma type time should be the same

Prisma information

Environment & setup

  • OS: Mac OS, Ubuntu
  • Database: PostgreSQL
  • Node.js version: 16

Prisma Version

4.3.0
@annibuliful annibuliful added the kind/bug A reported bug. label Aug 31, 2022
@phongkt-dev
Copy link

Same here, 74 models took 631.71s.

Generated Prisma Client (4.3.0 | library) to ./node_modules/@prisma/client in 631.71s

@capaj
Copy link

capaj commented Aug 31, 2022

holey moley that could be why my yarn install is taking so long 😱

@capaj
Copy link

capaj commented Aug 31, 2022

Yes same here-with 4.2.1 it took under 3 seconds. 4.3.0 just took 418 seconds.

@capaj
Copy link

capaj commented Aug 31, 2022

@annibuliful may I suggest you update the title to say Prisma 4.3.0 takes 100x more time to generate types, the title as it is does not do justice to the severity of this issue

@annibuliful annibuliful changed the title Prisma 4.3.0 take more time to generate types Prisma 4.3.0 takes 100x more time to generate types Aug 31, 2022
@annibuliful
Copy link
Author

@capaj Thank you very much

@annibuliful
Copy link
Author

My Github Action exceed the limit now 😭 😭 😭 😭 😭

@jkomyno
Copy link
Contributor

jkomyno commented Aug 31, 2022

Hi @annibuliful, @phongkt-dev, @capaj, can you please share your schema with us? It'd be very useful for investigating this issue, thanks.

@jkomyno jkomyno added bug/0-unknown Bug is new, does not have information for reproduction or reproduction could not be confirmed. team/client Issue for team Client. topic: type performance labels Aug 31, 2022
@SevInf SevInf self-assigned this Aug 31, 2022
@capaj
Copy link

capaj commented Aug 31, 2022

actually I tried with my schema that is open source and there is no slowdown on that schema. It's only the confidential schema where I have the problem.
I will ask my boss for a permission to send this over and get back to you @jkomyno

@jkomyno
Copy link
Contributor

jkomyno commented Aug 31, 2022

Thank you @capaj! You can even send the schema privately to schemas@prisma.io.
We can also sign an NDA for confidentiality if that's deemed necessary.

@capaj
Copy link

capaj commented Aug 31, 2022

Check you inbox.

@annibuliful
Copy link
Author

@jkomyno This is my schema
https://gist.github.com/annibuliful/570135fd4d9726a2eff7d19de8c155e7

@janpio
Copy link
Member

janpio commented Aug 31, 2022

Just to make explicit:
You did not explicitly enable any of the new preview features we introduced in 4.3.0, correct?

@janpio janpio added bug/1-unconfirmed Bug should have enough information for reproduction, but confirmation has not happened yet. kind/regression A reported bug in functionality that used to work before. and removed bug/0-unknown Bug is new, does not have information for reproduction or reproduction could not be confirmed. kind/bug A reported bug. labels Aug 31, 2022
@annibuliful
Copy link
Author

annibuliful commented Aug 31, 2022

Yes I used the same as V4.2.1

@capaj
Copy link

capaj commented Aug 31, 2022

same here-I just have

  previewFeatures = ["interactiveTransactions"]

SevInf added a commit that referenced this issue Aug 31, 2022
In #14982, we introduced generic input types and a function for
determining if particular input type needs generic argument. That
function traversed whole type graph starting with given types in search
for field references. It did not do any caching, so if particular type
was encountered multiple types in different relations, whole traversal
happened each time.

Fixed by replacing that helper function with a class with a built-in
cache for results. Now, each type would be checked at most once.

Fix #15109
@Jolg42
Copy link
Member

Jolg42 commented Aug 31, 2022

Thanks for the report and schemas.
@SevInf is working on a fix 👨‍🔧

We'll keep you updated as we are thinking about doing a patch release for this.

@janpio janpio added the topic: prisma generate CLI: prisma generate label Aug 31, 2022
SevInf added a commit that referenced this issue Aug 31, 2022
In #14982, we introduced generic input types and a function for
determining if particular input type needs generic argument. That
function traversed whole type graph starting with given types in search
for field references. It did not do any caching, so if particular type
was encountered multiple types in different relations, whole traversal
happened each time.

Fixed by replacing that helper function with a class with a built-in
cache for results. Now, each type would be checked at most once.

Fix #15109
SevInf added a commit that referenced this issue Sep 1, 2022
In #14982, we introduced generic input types and a function for
determining if particular input type needs generic argument. That
function traversed whole type graph starting with given types in search
for field references. It did not do any caching, so if particular type
was encountered multiple types in different relations, whole traversal
happened each time.

Fixed by replacing that helper function with a class with a built-in
cache for results. Now, each type would be checked at most once.

Fix #15109
SevInf added a commit that referenced this issue Sep 1, 2022
In #14982, we introduced generic input types and a function for
determining if particular input type needs generic argument. That
function traversed whole type graph starting with given types in search
for field references. It did not do any caching, so if particular type
was encountered multiple types in different relations, whole traversal
happened each time.

Fixed by replacing that helper function with a class with a built-in
cache for results. Now, each type would be checked at most once.

Fix #15109
@SevInf
Copy link
Contributor

SevInf commented Sep 1, 2022

Hey everyone!
Fix is now have been merged into main branch. It will be released with 4.3.1 later today.
If you are experiencing this issue, I'd suggest you hold off 4.3 update until patch is released.
Alternatively, you can verify that the fix is working for you by using dev snapshot version 4.4.0-dev.14, but we do not recommend using dev versions in production.

@Jolg42 Jolg42 added this to the 4.4.0 milestone Sep 1, 2022
millsp pushed a commit that referenced this issue Sep 1, 2022
In #14982, we introduced generic input types and a function for
determining if particular input type needs generic argument. That
function traversed whole type graph starting with given types in search
for field references. It did not do any caching, so if particular type
was encountered multiple types in different relations, whole traversal
happened each time.

Fixed by replacing that helper function with a class with a built-in
cache for results. Now, each type would be checked at most once.

Fix #15109

(cherry picked from commit 6b1a5fa)
@capaj
Copy link

capaj commented Sep 2, 2022

tested today with 4.3.1, problematic schema built in 3 seconds. Nicely done!

@Jolg42
Copy link
Member

Jolg42 commented Sep 2, 2022

Thanks for the feedback!

4.3.1 is now published https://github.com/prisma/prisma/releases/tag/4.3.1

@janpio janpio added bug/2-confirmed Bug has been reproduced and confirmed. and removed bug/1-unconfirmed Bug should have enough information for reproduction, but confirmation has not happened yet. labels Sep 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug/2-confirmed Bug has been reproduced and confirmed. kind/regression A reported bug in functionality that used to work before. team/client Issue for team Client. topic: prisma generate CLI: prisma generate topic: type performance
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants