samchon / typia

Super-fast/easy runtime validators and serializers via transformation
https://typia.io/
MIT License
4.63k stars 159 forks source link

Transform Performance Slow #1303

Open timoxley opened 1 month ago

timoxley commented 1 month ago

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 commented 1 month ago

I think this might be more relevant for unplugin-typia. https://github.com/ryoppippi/unplugin-typia/issues/334

timoxley commented 1 month ago

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?

ryoppippi commented 1 month ago

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

timoxley commented 1 month ago

@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 commented 1 month ago

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 https://github.com/ryoppippi/unplugin-typia/issues/334 again. In this issue, we discuss typia's transformer itself. We'll discuss unplugin-typia's improvement in another issue!