workerd
workerd copied to clipboard
Implement climem memory monitor service
climem is a tool that I've used extensively in the past for diagnosing memory leaks in node.js applications. It provides simple monitoring of v8 memory usage and rss for the application and displays it in a chart in the terminal.
This PR implements support for climem directly within workerd. The workerd portion of it is implemented as a simple TCP server (per isolate) that, when connected, generates a json-serialized log of the current memory stats for the process/isolate.
To use, specify the -m localhost option when running workerd serve. Then install climem from npm and run it, pointing at the tcp port that worker tells you the climem server is running on.
It's extremely rudimentary but that's the goal. Keep it simple.
/cc @mcollina who wrote climem
@admah — we should figure out the interface for Wrangler, so that you can say "turn on memory monitoring" and show this output in the terminal
Meant to open this as a draft PR as it's not going to ready to land for a bit. Reviews are welcome but it's probably not going to be a super high priority to finish up.