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

perf: Optimize codegen by ~20% #477

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

robertt
Copy link

@robertt robertt commented Jan 3, 2025

As our Prisma schema has grown (now 3,695 lines, 117 models, and 1,809 fields), typegraphql-prisma generation has become a significant bottleneck, taking ~50 seconds in CI and production builds. This has a noticeable impact on iteration velocity.

This PR improves schema generation time by ~20% (std. dev. 3.96% across 100s of benchmarks) through:

  • Parallel processing in cpu-aware batches
  • Fine-grained caching for models, enums, inputs, and outputs
  • Project-specific cache isolation
  • Memory-stable batch execution

We’re patch-packageing this internally for now but would love to see it upstream. Let me know if you have any feedback or
questions!

As an aside, here are some more architectural improvements I think would speed it up much more significantly but I didn't have time to get to. Happy to discuss more if you're interested.

  • Implement AST pooling system to cache and reuse common TypeScript AST nodes
  • Add parallel file I/O and memory pooling for field generation
  • Incremental compilation support for faster subsequent generations

@MichalLytek MichalLytek added enhancement New feature or request community Something initiated by the community labels Jan 5, 2025
@MichalLytek MichalLytek self-requested a review January 5, 2025 11:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
community Something initiated by the community enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants