A node.js back end is experiencing some speed issues and I’m trying to investigate. The back end is actually lightweight and the call having the issues is mostly performing a GET request to another service, getting a stream out of it and sending it back, chunk by chunk, to the client, while doing some light processing to each chunk (think of: O(n) on the size of the chunk). So, it’s very I/O bound.
I’m looking at node profiling, especially using chrome dev tools and flamegraphs. Apparently, the statistical profiler will (correctly) sample functions on the frame, so apparently it will not report the duration of tasks that are waiting. So, for example, if fetching a chunk from the stream is slow, I will not see that directly in the profiler.
I would like to see a profile where time to complete a task is actually wall-clock time, not CPU time, so if an async task takes a little CPU, but long wall clock time, I would like to see that (e.g. with setTimeout
).
What is the proper way to do that? Am I using the wrong tools?
I tried using the prof
tool and the --perf
node option, but without success: they are looking at the stack, so tasks awaiting are not reporting. I don’t know any other tool to profile node, so I’m not sure what to use. Ideally, I would like to have a tool that shows the wall-clock time a certain line of code took to complete.