tsx icon indicating copy to clipboard operation
tsx copied to clipboard

TSX appears to be utilizing too much CPU

Open npearson72 opened this issue 10 months ago • 0 comments

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

Image

tsx

Image

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

npearson72 avatar Jan 21 '25 01:01 npearson72