DTrace Your Node.js JS

Mark Cavage

dtrace.conf April 03, 2012

Me

Just to level-set (i.e., What's Node.js?)

What's Node.js?

Why would you use Node.js?

Bored now. What's this talk about?

DTrace the Node core

Some One-liners (thanks @bmc)

Cool - do I need anything else?

What if your infrastructure looks like this?

Suppose you had some (crappy) REST api...

Wouldn't it be nice to see that slowdown?

In action?

Wait. What?

Thanks Chris Andrews!

$ npm install dtrace-provider

What is node-dtrace-provider?

Is this magic? How does this work?

How do you use it?

Node's read vs system read

Pretty decent in terms of interpreter overhead (μs)

(Tangent) What's with the goofy read:return?

Bah! Show me some examples!

ldapjs: hello world server

Show me the probes!

Some search one(ish) liners

Fancy: Visualization of ldapjs

That said: it's pretty course granularity

Take two: restify

A (slightly) bigger exampe

Now we're talking!

The same D script as before...

Shows us a lot more data

Every time a route/handler is added

mapping code

Route runner fires

Some tips on how to use dtrace-provider...

Ride on top of other probes

Whenever possible, piggyback on system probes by using an argument you can correlate (like filename in the nodecat example)

Picking arguments

There's no support for argument structs (yet), and you only get 6 arguments to play with, so choose your args wisely

Build into your framework

ldapjs and restify are two examples where DTrace isn't in user code at all, but provides substantial value.

  • Most nodey things end up in a control-flow problem
  • I.e., everybody I know uses async or a home-grown thing like it.
  • But that makes an excellent place to put probes.
  • Easy latency tracking

    What would be nice in the future?

    And with that...

    Questions?

    /

    #