npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

node-stap

v1.0.3

Published

Tools for profiling Node with SystemTap.

Downloads

4

Readme

Synopsis

Tools for profiling Node.js programs. Uses SystemTap to collect and symbolicate JavaScript backtraces, extracting human-readable names by walking the V8 stack and heap. Uses wrapper scripts and node-stackvis to generate textual or HTML flamegraphs. Can also output text suitable for input to to [FlameGraph] (https://github.com/brendangregg/FlameGraph).

Inspired and informed by Dave Pacheco's excellent V8 DTrace ustack helper.

Safety

SystemTap is invasive; recommended to try in safe environments before running in production!

Caveats

  • Only works on 64-bit node processes.
  • Line numbers are best effort (not always available) and refer to the start of a function.
  • Only tested on node0.10 so far.
  • Stacks may omit inlined functions.
  • Also may elide frames on very deep stacks to avoid doing too much work in SystemTap probe context.

Basic Usage

[~/uber/node-stap]$ sudo cmd/torch.js 
Usage: torch <pid> <text|flame|raw> <duration (s)>
    text: textual flame graph.
    flame: html flame graph.
    raw: format suitable for input to FlameGraph tools.

HTML Example

dh@dh:~/node-stap$ sudo cmd/torch.js 24701 flame 10 > /tmp/flame.html
Sampling 24701 for 10s, outputting flame.

dh@dh:~/node-stap$ # done

Raw Example

dh@dh:~/node-stap$ sudo node cmd/torch.js 2291 raw 10 > ../raw.txt
Sampling 2291 for 10s, outputting raw.

dh@dh:~/node-stap$ cd ../FlameGraph/
dh@dh:~/FlameGraph$ ./stackcollapse.pl < ../raw.txt  > ../collapsed.txt
dh@dh:~/FlameGraph$ ./flamegraph.pl < ../collapsed.txt  > ../flame.svg

Text Example

dh@dh:~/node-stap$ cat ../test.js
var dummy = new Error().stack; // Persuade v8 to compute line numbers

while(true) {
    console.log("Hello!");
}
dh@dh:~/node-stap$ node ../test.js  > /dev/null & 
[1] 2291
dh@dh:~/node-stap$ sudo node cmd/torch.js 2291 text 10
Sampling 2291 for 10s, outputting text.

Total samples: 747
747 node::Start(int, char**):[native]
  747 node::Load(v8::Handle<v8::Object>):[native]
    747 v8::Function::Call(v8::Handle<v8::Object>, int, v8::Handle<v8::Value>*):[native]
      747 v8::internal::Execution::Call(v8::internal::Handle<v8::internal::Object>, v8::internal::Handle<v8::internal::Object>, int, v8::internal::Handle<v8::internal::Object>*, bool*, bool):[native]
        747 [0x72a82a in /usr/bin/nodejs]:[native]
          747 [entry frame]
            747 [internal frame]
              747 [empty]:[unknown]:26
                747 startup:[unknown]:29
                  747 Module.runMain:module.js:494
                    747 Module._load:module.js:274
                        ... [more]

Installation

You'll need SystemTap and headers for your kernel version installed on your system. Other than that, just clone and profile as above. Tested with SystemTap 2.7 on linux 3.2.0-79-generic.

Tests

All things in the fullness of time.

Contributors

dh

Future Work

32-bit processes, edge cases in native code symbolication.

License

node-stap is available under the MIT license. See the LICENSE file for more info.