No description or website provided.
Rust Shell
Latest commit d3727d1 Oct 14, 2016 @jvns committed on GitHub add statistics disclaimer to the readme

README.md

ruby-stacktrace

Have you ever wanted to know what your Ruby program is doing? ruby-stacktrace can tell you! Maybe.

this is alpha, Linux-only software. It will very likely crash. If it crashes, the rest of your system should probably be fine (it shouldn't crash your Ruby). But I wouldn't totally swear that.

Also there are known problems with the sampling and how it calculates statistics about your program. Do not take the results of this program as gospel, especially if your computer is under a lot of CPU load. That said, at least 1 person has found it useful in the past.

If you want something that actually works more reliably and is more mature, consider using stackprof

Requirements

  1. Linux (It uses a Linux-only system call)
  2. The most recent pre-release of ruby-stacktrace (download from here)
  3. A Ruby version compiled with debugging symbols (check by running file on your Ruby binary)

I've tested this succesfully on Ruby versions 2.1.6 and 2.2.3. No promises though. It works on my computer and at least 2 other computers.

How to use it

  1. Download recent release of ruby-stacktrace (download from here)
  2. Find the PID of the Ruby process you want to investigate (like 7723)
  3. run sudo ./ruby-stacktrace top 7723
  4. It'll either work (and tell you which functions are being called the most) or crash
  5. I would not run this on a production system today, but I don't know of any specific reason you shouldn't (other than that it's sketchy alpha software)

If it crashes, you can file an issue and attach the Ruby binary for the process it couldn't spy on. I will read all the issues and help if I can! Especially if it's just that something in this README is explained poorly. I have approximately no time to fix issues, so I will probably not fix the bug. Pull requests are very welcome!

Generating flamegraphs

You can use this tool to generate flamegraphs for a running Ruby process.

  1. Get the FlameGraph repository and add it to your PATH
  2. Run sudo ./ruby-stacktrace stackcollapse $PID > stacks until you get bored of collecting data
  3. run stackcollapse.pl < stacks | flamegraph.pl > output.svg
  4. Open output.svg! You should get a beautiful graph like this: (click to enlarge)

How it works

I wrote a blog post about the internals at How to spy on a Ruby process

Developing ruby-stacktrace

It's written in Rust.

  1. Install cargo from crates.io
  2. cargo build to build
  3. cargo test to test
  4. cargo bench for benchmarks

The build artifacts will end up in target/release

Authors

(in alphabetical order)

  • Julia Evans
  • Kamal Marhubi