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

Transform Performance Slow #1303

Open
timoxley opened this issue Sep 27, 2024 · 7 comments
Open

Transform Performance Slow #1303

timoxley opened this issue Sep 27, 2024 · 7 comments

Comments

@timoxley
Copy link

I have a small vite/vitest application with a handful of tests. The tests take a long time to cold-start and it appears they are getting slowed down by the typia transform: ~15 seconds for ~15 files.

Is there something that can be configured to make it transform faster, e.g. caching, parallelism or something, or is this perhaps a limitation of esbuild/tsc/vite? Any suggestions or additional information I can provide?

~15 seconds for ~15 files

output of vite-plugin-inspect showing typia transform being slow         output of vite-plugin-inspect showing files using typia being the slow ones

AFAICT I'm on the latest version of all relevant packages.

    "typescript": "^5.6.2",
    "typia": "^6.11.0",
    "vite": "^5.4.4",
    "vite-plugin-inspect": "^0.8.7",
    "vitest": "^2.1.1"
@timoxley
Copy link
Author

I think this might be more relevant for unplugin-typia. ryoppippi/unplugin-typia#334

@timoxley
Copy link
Author

timoxley commented Sep 30, 2024

you know what, I think it may be typia itself, I don't know?

I created a kind of subset of my setup in the typia playground

When I import this file and build it with my app, via vite, it takes ~1.5 seconds. ~1.5s is fine if this was the only file, but in my full (simple) app these add up to about 30s of additional build time 🎻😿. This file has no external deps (other than typia), so I'm starting to doubt my suspicion that it's an issue with the way the unplugin plugin sets up the ts context per-file (see issue I opened on the plugin).

image

What do you think @samchon, @ryoppippi?

@timoxley timoxley reopened this Sep 30, 2024
@ryoppippi
Copy link
Contributor

@timoxley Wait, is unplugin-typia process every single file?
unplugin-typia skips processing a file without a keyword typia

@timoxley
Copy link
Author

@timoxley Wait, is unplugin-typia process every single file?
unplugin-typia skips processing a file without a keyword typia

It's processing all the files with the typia keyword, that seems to be working correctly.

@ryoppippi
Copy link
Contributor

It's processing all the files with the typia keyword, that seems to be working correctly.

Yeah, so idk why it slows so much.

Anyway, I reopen ryoppippi/unplugin-typia#334 again. In this issue, we discuss typia's transformer itself. We'll discuss unplugin-typia's improvement in another issue!

@ziongh
Copy link

ziongh commented Feb 18, 2025

I've tested using the plugin (unplugin-typia) and using the Generation method:

pnpm typia generate \
  --input src/templates \
  --output src/generated \
  --project tsconfig.json

And the problem is the same on both: When the file containing all Typia methods is really large the generation proccess halt and eventually gives a JavaScript heap out of memory.

The scenario that I'm using Typia is to generate validation methods for each API request body and response object that comes from an OpenAPI document. So there are thousands of types to check and the generation proccess cannot finish.

It would be nice to have some kind of partial generation, where it would generate and save partial validators to free the memory.

@lcardosol
Copy link

I've just finished migrating a project to use Nestia/Typia, only to find out that my builds for development take up to 12 minutes, this has made my development process very slow, if I need to restart the app for some reason I have to wait all over again and I'm not even using unplugin-typia, I've used the setup cli command from the documentation so I'm not sure if I misconfigured something, when running the tsc command I see that one particular file takes longer and it is the only one that contains a DTO that's relatively complex, have anyone found a way to improve that?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants