#Proposal for a Documentation Improvement Regarding TypeScript Performance

9 messages · Page 1 of 1 (latest)

scarlet perch
#

Hi everyone,

I recently ran into a significant IDE performance issue in my project with Prisma, and after some digging, I was lucky enough to pinpoint the cause.

The core of the problem isn't an issue with Prisma itself, but rather a subtle pitfall in how Prisma's generated types are used within TypeScript. I believe other developers might easily encounter the same thing.

I wrote a post on a Japanese tech blog (Zenn) about my findings, which was well-received. I've also posted a summarized English version on my personal blog here for context:
https://www.toyb0x.me/blog/prisma-type-performance-optimization-en/

To contribute back to the community and as a personal challenge, I'd love to create a PR to add this knowledge and a recommended code example to the official Prisma documentation.

I was thinking it might fit well in the section on Client Extensions, perhaps somewhere around here:
https://github.com/prisma/docs/blob/main/content/200-orm/200-prisma-client/300-client-extensions/index.mdx#add-an-extension-to-prisma-client

What do you think would be the best place for this kind of tip?
I'm open to any suggestions or feedback, even if you think a documentation update isn't necessary for this.

Thanks in advance!

brisk marshBOT
#

You decided to hold for human wisdom. We'll chime in soon! Meanwhile, #ask-ai is there if you need a quick second opinion.

shut heart
#

Hey!

Please fell free to open a Docs PR so that our team can have a look and provide insights. It would be good if you can provide benchmarks and details on how you tested both approaches 🙂

scarlet perch
#

Thank you.
I will create a PR later.

Also, for now I will leave here the results of the measurement using the test PR mentioned in the above document.

scarlet perch
#

@shut heart

I've created a PR to add doc for performance optimization with benchmarks codes.
I think this would be very valuable to the Prisma community, so I hope it will be prioritized and reviewed.

Also, if I need to send a review request to someone on GitHub, please let me know who I should send it to.

PR #7000:
TypeScript performance optimization guide for large Prisma schemas
https://github.com/prisma/docs/pull/7000

GitHub

Problem
Enterprise users with large Prisma schemas frequently hit severe TypeScript compilation bottlenecks—compilation times of several minutes, memory issues, and unresponsive IDEs. This is a com...

scarlet perch
#

@sick monolith @lofty cape @vital solstice
I will also mention other members of this channel who I believe to be Prisma staff.

(I'm worried because it seems like there is no reviewer in the above repository.)

scarlet perch
#

@pallid notch cc @shut heart
Hi, I mentioned you because it looked like you had review permissions on Github.

It seems that the permission settings on Github do not allow me to send a review request.

Please let me know if there are any steps I should take to start the review process for the following PR.
https://github.com/prisma/docs/pull/7000

GitHub

Problem
Enterprise users with large Prisma schemas frequently hit severe TypeScript compilation bottlenecks—compilation times of several minutes, memory issues, and unresponsive IDEs. This is a com...

shut heart
#

Thank you for creating the Docs PR. Our team will take a look as soon as possible.

scarlet perch
#

@shut heart
Thank you for your reply!

By the way, TypeScript's type system is sometimes difficult.

Benchmarks have revealed that typeof can significantly speed up cases, and in the projects I'm involved in, by adjusting just a few lines of code, we were able to roughly improve processing by 5 to 10 times.

On the other hand, typeof is technically different between JavaScript and TypeScript, so I'm a little worried about the technical validity of this, so if there are any type system specialists out there, I'd appreciate it if you could review it thoroughly.
(If there are any technical parts of the text that need to be revised, I'll make the corrections as soon as possible.)

PS:
I've added a commit to fine-tune the explanation to make it more appropriate.
https://github.com/prisma/docs/pull/7000/commits/c57da35e1ef244d292e704399d002c3321e678be