Git Product home page Git Product logo

dtracestackstopprof's Introduction

DTraceStacksToPprof

This is a tool used to convert performance profiles collected from DTrace to pprof, enabling graphical representation of the frequency of occuring stacks.

Getting started

First clone the repo,

$ git clone https://github.com/google/dtraceStacksToPprof.git

The tool requires Go, which can be downloaded at the Go homepage

dtraceStacksToPprof can be installed to the GOPATH using

go install github.com/google/dtraceStacksToPprof

or run directly in the repo using

go run main.go

How to use

The converter supports stack output produced by DTrace, in the following pseudo BNF syntax:

  <input> ::= <prologue> <stacks>
  <prologue> = { JUNK_LINE }
  <stacks> ::= { <stack> }
  <stack> ::= STACK_HEADER <frames> COUNT
  <frames> ::= { <frame> }
  <frame> ::= HEX_ADDRESS | FUNCTION
  JUNK_LINE ::= (string not matching STACK_HEADER)
  STACK_HEADER ::= ^\s*[\S\s]+\s*:$  (a sentence ending with a colon, optionally
                                      surrounded by white space)
  COUNT ::= ^\s*[0-9]+\s*$  (a sole decimal digit, optionally surrounded by
                             white space)
  HEX_ADDRESS ::= ^\s*0x[0-9a-fA-F]+\s*$ (a hexadecimal address, optionally
                                          surrounded by white space)
  FUNCTION ::= ^\s*[\S]+`.*\+?\S*$ (non-whitespace, backtick, non-whitespace,
                                    followed by an optional plus sign and
                                    optional non-whitespace after, all
                                    optionally surrounded by white space)

It's designed to take the output of dtrace scripts like the following:

#!/bin/dtrace -s
syscall:::entry {
  @aggr["Label:", ustack()] = count();
}
tick-1s {
  printa(@aggr);
}

The dtraceStacksToPprof tool reads text from stdin and produces a pprof protobuf. To produce a pprof directly from dtrace, simply pipe dtrace's output into dtraceStacksToPprof like

$ sudo dtrace -s <script name> -p <target pid> | dtraceStacksToPprof

or store to an intermediate text file and then convert.

$ dtraceStacksToPprof < <intermediate file>

The tool writes to profile.pb.gz by default, but the output file name can be customized via the --output command line flag:

$ dtraceStacksToPprof --output InterestingBehavior.pb.gz < <intermediate file>

Disclaimer

This is not an officially supported Google product.

dtracestackstopprof's People

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.