tsx
tsx copied to clipboard
TSX appears to be utilizing too much CPU
Acknowledgements
- [x] I read the documentation and searched existing issues to avoid duplicates
- [x] I understand this is a bug tracker and anything other than a proven bug will be closed
- [x] I understand this is a free project and relies on community contributions
- [x] I read and understood the Contribution guide
Minimal reproduction URL
https://github.com/expressjs/express
Problem & expected behavior (under 200 words)
- What happened
I deployed a basic express app (hello world) using tsx and noticed CPU spikes. I then deployed the same app with ts-node and the spikes went away.
I then built a docker image and ran a benchmark with wrk: wrk -t12 -c400 -d30s http://localhost:3000/api
I had the following benchmark utils setup in the /api endpoint:
console.log(process.memoryUsage());
for (const [key, value] of Object.entries(process.memoryUsage())) {
console.log(`Memory usage by ${key}, ${value / 1000000}MB `);
}
console.log(process.cpuUsage());
- What I expected
I expected tsx to perform better than ts-node. But as you can see from the screenshots below, it unfortunately does not.
In my tests tsx is consuming 3x the CPU.
I'm very interested in using tsx and hope this is something that can be reasolved.
- Screenshots
ts-node
tsx
Bugs are expected to be fixed by those affected by it
- [ ] I'm interested in working on this issue
Compensating engineering work will speed up resolution and support the project
- [ ] I'm willing to offer $10 for financial support