Git Product home page Git Product logo

pprofutils's Introduction

documentation ci test status

pprofutils

pprofutils provides command line utilities for converting pprof files to Brendan Gregg's folded text format and vice versa.

Install

pprofutils requires Go 1.16 and can be installed like this:

go install github.com/felixge/pprofutils/cmd/...@latest

Usage

Convert a pprof file to text:

pprof2text < ./test-fixtures/pprof.samples.cpu.001.pb.gz > example.txt

Convert a text file to pprof:

text2pprof < example.txt > example.pprof

Warning: Converting from pprof to text is lossy. Only the first sample type will be converted, file names, lines, labels, and more will be dropped. Patches to make things less lossy would be welcome, but please open an issue first to discuss.

Create a delta profile that contains the difference heap-b.pprof - heap-a.pprof:

pprofdelta -o delta.pprof heap-a.pprof heap-b.pprof

Tutorial: Generate a fake pprof profile

My primary use case for this tool is to quickly generate fake pprof profiles for creating educational content.

This can be done by simply creating a file called profile.txt with the following content:

main;foo 5
main;foo;bar 3
main;foobar 4

Then convert it to a pprof profile:

text2pprof < profile.txt > profile.pprof

And finally view it using pprof:

go tool pprof -http=:6060 profile.pprof

The resulting graphs should look like this:

Custom Extension: Multiple Sample Types

The text2pprof command supports a custom extension to the folded text format that allows users to specify multiple sample types.

This is done via a header that contains space separated type/unit sample types. The stack traces on the following lines must then contain one value for each sample type after the stack trace:

samples/count duration/nanoseconds
main;foo 5 50000000
main;foo;bar 3 30000000
main;foobar 4 40000000

The pprof2text command also supports outputting this format by passing the -m flag.

License

pprofutils is licensed under the MIT License.

pprofutils's People

Contributors

felixge avatar

Watchers

James Cloos 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.