I use @swc-node to run TypeScript backend in production. because i don't like to add a build step to my workflow, on-the-fly transpilation just makes life easier
everything works fine, but the extra memory usage caused by swc is a downside to me.
to reproduce:
import { memoryUsage } from "node:process";
setInterval(() => {
console.log(memoryUsage());
}, 2000);
node main.js: rss: 45MB, heapTotal: 6MB, heapUsed: 6MB, external: 421KB, arrayBuffers: 18KB
deno main.ts: rss: 52MB, heapTotal: 11MB, heapUsed: 10MB, external: 76KB, arrayBuffers: 0
node -r @swc-node/register main.ts: rss: 102MB, heapTotal: 30MB, heapUsed: 23MB, external: 592KB, arrayBuffers: 57KB
There is a huge gap here. I was able to 60% reduce one of my project rss, just by compiling the source code before runtime.
I wonder is there anyway to consume less memory for production usage? maybe unload/free the swc compiler after a while during runtime.
I can work on a PR, but i have no idea to start
I use
@swc-nodeto run TypeScript backend in production. because i don't like to add a build step to my workflow, on-the-fly transpilation just makes life easiereverything works fine, but the extra memory usage caused by swc is a downside to me.
to reproduce:
node main.js: rss: 45MB, heapTotal: 6MB, heapUsed: 6MB, external: 421KB, arrayBuffers: 18KBdeno main.ts: rss: 52MB, heapTotal: 11MB, heapUsed: 10MB, external: 76KB, arrayBuffers: 0node -r @swc-node/register main.ts: rss: 102MB, heapTotal: 30MB, heapUsed: 23MB, external: 592KB, arrayBuffers: 57KBThere is a huge gap here. I was able to 60% reduce one of my project rss, just by compiling the source code before runtime.
I wonder is there anyway to consume less memory for production usage? maybe unload/free the swc compiler after a while during runtime.
I can work on a PR, but i have no idea to start