You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Let's say I have a monorepo with 2 subprojects and 30 small ts files in total.
swc uses memory more smoothly in total, about ~390mb on start, then frees up memory up to ~350mb after ~1min.
tsc works with large peaks, reaching ~130mb on start, ~275mb after any changes in file (even more after several successive changes), then frees up memory up to ~110mb after ~1min. tsc also loads the processor more with peaks.
All numbers without running node process and taken from docker stats. exclude options configured in both cases, even node_modules folders deleted, for the sake of the purity of the experiment.
The question is, should swc really use so much memory for 30 files? I assumed that it would be at least a couple of times less than tsc.
The question is, can someone share their conclusions about a similar kind of testing in watch mode?
UPDATE
after further research I found a couple of bottlenecks. pnpm exec and npx gives additional overhead on memory, better to run the command directly from node_modules:
running the command via npx
swc: uses ~345mb of memory on start, on file change no change in memory consumption and ~330mb after 1min of inaction
tsc: uses ~80mb of memory on start, ~220mb on file change and ~85mb after 1min of inaction.
running the command directly from node_modules:
swc: uses ~310mb of memory on start, on file change and after 1min of inaction there is no change in memory consumption
If run swc with --workers 1 it consumes less memory: ~195mb on start (directly from node_modules), on file change and after 1min of inaction there is no change in memory consumption
tsc: uses ~50mb of memory on start, ~200mb on file change and ~60mb after 1min of inaction
without --noCheck uses ~200mb of memory on start, ~300mb on file change and ~65mb after 1min of inaction
The rest of the memory consumption is probably due to the chokidar library.
Found an interesting topic vitejs/vite#13593
It might be worthwhile to stop using chokidar and use @parcel/watcher instead.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I am currently testing how much memory tsc and swc use in watch mode.
What I am using:
macos
docker desktop
docker compose watch with
sync
actionnode:22.7.0-bookworm-slim
pnpm 9.9.0
Let's say I have a monorepo with 2 subprojects and 30 small ts files in total.
swc uses memory more smoothly in total, about ~390mb on start, then frees up memory up to ~350mb after ~1min.
tsc works with large peaks, reaching ~130mb on start, ~275mb after any changes in file (even more after several successive changes), then frees up memory up to ~110mb after ~1min. tsc also loads the processor more with peaks.
All numbers without running node process and taken from docker stats.
exclude
options configured in both cases, evennode_modules
folders deleted, for the sake of the purity of the experiment.how I run swc
how I run tsc (composite with 2 subprojects)
The question is, should swc really use so much memory for 30 files? I assumed that it would be at least a couple of times less than tsc.
The question is, can someone share their conclusions about a similar kind of testing in watch mode?
UPDATE
after further research I found a couple of bottlenecks.
pnpm exec
andnpx
gives additional overhead on memory, better to run the command directly fromnode_modules
:running the command via
npx
running the command directly from
node_modules
:--workers 1
it consumes less memory: ~195mb on start (directly from node_modules), on file change and after 1min of inaction there is no change in memory consumption--noCheck
uses ~200mb of memory on start, ~300mb on file change and ~65mb after 1min of inactionThe rest of the memory consumption is probably due to the
chokidar
library.Found an interesting topic vitejs/vite#13593
It might be worthwhile to stop using
chokidar
and use@parcel/watcher
instead.Beta Was this translation helpful? Give feedback.
All reactions