slowjam

module
v1.0.0-beta.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 30, 2020 License: Apache-2.0

README

NOTE: This is not an officially supported Google product

SlowJam is a tool for analyzing the performance of Go applications which consume substantial wall-clock time, but do not consume substantial CPU time. For example, an automation tool which primarily waits on command-line execution or remote resources to become available.

Go has great profiling and tracing support for applications which consume many resources, but does not have a low-touch story for profiling applications that primarily wait on external resources.

Features

  • Stack-based sampling approach
  • Minimal instrumentation (2 lines of code to integrate)
  • Minimal & tunable overhead (~1% for the small workloads we have tested)
  • Hybrid Gantt/Flamegraph visualization

Screenshot

screenshot

See example/minikube.html for example output.

Requirements

  • Go v1.14 or higher

Usage

Recording

SlowJam contains a package named stacklog, which includes the minimal code required to record data for analysis. The simplest way to get started is invoking this in the main() method of your binary. This tells the stack logger to run in a default configuration if STACKLOG_PATH is set in the environment, and will record data to that location.

s := stacklog.MustStartFromEnv("STACKLOG_PATH")
defer s.Stop()

If you prefer greater control over the configuration, you can also use:

s, err := stacklog.Start(stacklog.Config{Path: os.Getenv("STACKLOG_PATH")})
defer s.Stop()

By default, this will poll the stack every 125ms.

Visualization

Install slowjam:

go install github.com/google/slowjam/cmd/slowjam

Analyze a stacklog using the interactive webserver:

slowjam -http localhost:8080 /path/to/stack.slog

To output HTML:

slowjam -html out.html /path/to/stack.slog

Real World Example

SlowJam was built to make minikube go faster. Here's how we did it:

(TBD)

Directories

Path Synopsis
cmd
slowjam command
pkg
stacklog
Package stacklog logs the Go stack to disk in a loop for later analysis
Package stacklog logs the Go stack to disk in a loop for later analysis
stackparse
Package stackparse turns stacklogs into objects for analysis
Package stackparse turns stacklogs into objects for analysis
text
Package text is for rendering a timeline into text form
Package text is for rendering a timeline into text form
web
Package web is for generating HTML visualizations of stack logs
Package web is for generating HTML visualizations of stack logs
third_party
colornames
Package colornames provides named colors as defined in the SVG 1.1 spec.
Package colornames provides named colors as defined in the SVG 1.1 spec.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL