Shared publicly  - 
 
Look Ma, We Built a Profiler for Node.js

My partner in crime, +Guyon Roche, and I just built a really slick little profiler for Node.js that works surprisingly well. The reason we had to do it is that the current V8 profiler doesn't work with the more recent versions of Node and we need to try to squeeze as much efficiency as we can out of Uber's dispatch server due to the ridiculous amount of growth the service has been experiencing. Six months ago the dispatch server would maybe spike the server's CPU at 1.5 percent, but now it's looking like we're about to run out of headroom. Whoops! ;)

I'll have to talk to Uber about it, but if anyone's interested then I'll check to see if we can open source it or something.

By the way, the profiler has two dependencies: 1. the microtime node library, which provides access to the high-resolution timer on POSIX systems * , and 2. a JS inheritance method created by John Resig, which can be found here ** :

http://ejohn.org/blog/simple-javascript-inheritance/

* If you don't have a POSIX system (Windows), you could maybe extend microtime to access the equivalent Windows high-resolution timer, but I've never written a Node C++ module before, so I don't know how easy or hard that would be. My guess is that it would probably only be an afternoon hack seeing as how many of these half-assed Node.js libraries you see out there.

** If you have your own inheritance library, you could pretty easily replicate what we've done to integrate the profiler with Resig's code, so that probably wouldn't be a big deal either.
5
1
Benjamin Boyter's profile photoJason Roberts's profile photoWill Stone's profile photoMatt Bornski's profile photo
12 comments
 
+Pierre De Pascale If by statistical you mean that it samples only a fraction of the function calls, then no. This first version tracks every call (microseconds elapsed and invocation count) and displays the results in an ordered tree format as well as a flat format, sorted by percent of elapsed time. We're still adding to it, so making it statistical would be trivial, unless of course you mean something else entirely.
 
If it tracks everything what sort of performance overhead does it cause (if any)?
 
I'm definitely interested in this. We're moving some key pieces of our stack from Python to Node, and without the benefit of experience, a good profiler would be a nice piece of the toolbox.
 
+Matt Bornski I've been meaning to talk to Uber about the possibility of open sourcing it, but I'm guessing that they'll probably be open to it. So far it's already helped quite a bit in pinpointing inefficiencies in the dispatching system, so it was well worth the effort.
 
Did this ever get open-sourced?  I'd definitely be interested...
 
Eager to know if this is available to use?
Add a comment...