P
Prisma•4mo ago
Toyb0x

Proposal for a Documentation Improvement Regarding TypeScript Performance

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!
8 Replies
Prisma AI Help
Prisma AI Help•4mo ago
You decided to hold for human wisdom. We'll chime in soon! Meanwhile, #ask-ai is there if you need a quick second opinion.
Nurul
Nurul•4mo ago
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 🙂
Toyb0x
Toyb0xOP•4mo ago
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.
No description
Toyb0x
Toyb0xOP•4mo ago
@Nurul 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
docs: TypeScript performance optimization guide for large Prisma sc...
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...
Toyb0x
Toyb0xOP•4mo ago
@Luan @Tyler Benfield @jonfanz 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.)
Toyb0x
Toyb0xOP•4mo ago
@nikolasburk cc @Nurul 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
docs: TypeScript performance optimization guide for large Prisma sc...
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...
Nurul
Nurul•4mo ago
Thank you for creating the Docs PR. Our team will take a look as soon as possible.
Toyb0x
Toyb0xOP•3mo ago
@Nurul 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 Hi, I know the team is busy, but I'd like to gently follow up on this PR since it's been over a week. Any feedback would be greatly appreciated when you find a moment. Thank you.

Did you find this page helpful?