• Stars
    star
    109
  • Rank 319,077 (Top 7 %)
  • Language
    Go
  • License
    MIT License
  • Created over 8 years ago
  • Updated over 4 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Profiling deployed binaries in real-time with flame graphs and plots.

goprofui

A simple package for profiling deployed binaries.

Key features:

  • Does not require running any other scripts/tools, only the binary under monitoring.
  • Flame graphs for stack trace profiling.
  • Memory, GC pauses and goroutines line charts.

Related Work

  • go-torch. https://github.com/uber/go-torch. go-torch does cpu profiling and represents it as a flame graph. We were directly inspired by this package. In contrast to goprofui, go-torch requires the go pprof tool and an external Perl script.

  • profile. https://github.com/pkg/profile. profile does cpu and memory profiling, and saves them into a file. It is easy to setup and use. However, the cpu profiles would have to be further parsed for a flame graph.

  • flame graphs. http://www.brendangregg.com/flamegraphs.html. Created by Brendan Gregg. An extremely succinct way to summarize stack traces.

Installation

go get github.com/wirelessregistry/goprofui

Dependencies

  1. Requires the net web-socket library https://godoc.org/golang.org/x/net/websocket.

  2. The flame graph JS library is https://github.com/spiermar/d3-flame-graph.

  3. The line chart JS library is D3's.

  4. goprofui's internal package is forked from pprof's internal package. It is covered by the BSD-license in LICENSE_internal_pkg.

Usage and Code Structure

The quickest way to get started is to copy the handlers' setup from examples/web/web.go. Build the web.go application, and then serve the index.html file using a web server (https://github.com/indexzero/http-server for example).

When you visit the example using your web browser, you will see some graphs:

  • Alt text
  • Alt text
  • Alt text

The cpu profiling code is in cpu.go. The memory, GC latency and goroutines stats are obtained in tickerHandlers.go.