Debian Codegraph @

README.md

raw symbols SCIP
1 [![Github Action CI](https://github.com/google/pprof/workflows/ci/badge.svg)](https://github.com/google/pprof/actions)
2 [![Codecov](https://codecov.io/gh/google/pprof/graph/badge.svg)](https://codecov.io/gh/google/pprof)
3 [![Go Reference](https://pkg.go.dev/badge/github.com/google/pprof/profile.svg)](https://pkg.go.dev/github.com/google/pprof/profile)
4
5 # Introduction
6
7 pprof is a tool for visualization and analysis of profiling data.
8
9 pprof reads a collection of profiling samples in profile.proto format and
10 generates reports to visualize and help analyze the data. It can generate both
11 text and graphical reports (through the use of the dot visualization package).
12
13 profile.proto is a protocol buffer that describes a set of callstacks
14 and symbolization information. A common usage is to represent a set of
15 sampled callstacks from statistical profiling. The format is
16 described on the [proto/profile.proto](./proto/profile.proto) file. For details on protocol
17 buffers, see https://developers.google.com/protocol-buffers
18
19 Profiles can be read from a local file, or over http. Multiple
20 profiles of the same type can be aggregated or compared.
21
22 If the profile samples contain machine addresses, pprof can symbolize
23 them through the use of the native binutils tools (addr2line and nm).
24
25 **This is not an official Google product.**
26
27 # Building pprof
28
29 Prerequisites:
30
31 - Go development kit of a [supported version](https://golang.org/doc/devel/release.html#policy).
32 Follow [these instructions](http://golang.org/doc/code.html) to prepare
33 the environment.
34
35 - Graphviz: http://www.graphviz.org/
36 Optional, used to generate graphic visualizations of profiles
37
38 To build and install it:
39
40 go install github.com/google/pprof@latest
41
42 The binary will be installed `$GOPATH/bin` (`$HOME/go/bin` by default).
43
44 # Basic usage
45
46 pprof can read a profile from a file or directly from a server via http.
47 Specify the profile input(s) in the command line, and use options to
48 indicate how to format the report.
49
50 ## Generate a text report of the profile, sorted by hotness:
51
52 ```
53 % pprof -top [main_binary] profile.pb.gz
54 Where
55 main_binary: Local path to the main program binary, to enable symbolization
56 profile.pb.gz: Local path to the profile in a compressed protobuf, or
57 URL to the http service that serves a profile.
58 ```
59
60 ## Generate a graph in an SVG file, and open it with a web browser:
61
62 ```
63 pprof -web [main_binary] profile.pb.gz
64 ```
65
66 ## Run pprof on interactive mode:
67
68 If no output formatting option is specified, pprof runs on interactive mode,
69 where reads the profile and accepts interactive commands for visualization and
70 refinement of the profile.
71
72 ```
73 pprof [main_binary] profile.pb.gz
74
75 This will open a simple shell that takes pprof commands to generate reports.
76 Type 'help' for available commands/options.
77 ```
78
79 ## Run pprof via a web interface
80
81 If the `-http` flag is specified, pprof starts a web server at
82 the specified host:port that provides an interactive web-based interface to pprof.
83 Host is optional, and is "localhost" by default. Port is optional, and is a
84 random available port by default. `-http=":"` starts a server locally at
85 a random port.
86
87 ```
88 pprof -http=[host]:[port] [main_binary] profile.pb.gz
89 ```
90
91 The preceding command should automatically open your web browser at
92 the right page; if not, you can manually visit the specified port in
93 your web browser.
94
95 ## Using pprof with Linux Perf
96
97 pprof can read `perf.data` files generated by the
98 [Linux perf](https://perf.wiki.kernel.org/index.php/Main_Page) tool by using the
99 `perf_to_profile` program from the
100 [perf_data_converter](https://github.com/google/perf_data_converter) package.
101
102 ## Viewing disassembly on Windows
103
104 To view disassembly of profiles collected from Go programs compiled as Windows executables,
105 the executable must be built with `go build -buildmode=exe`. LLVM or GCC must be installed,
106 so required tools like `addr2line` and `nm` are available to `pprof`.
107
108 ## Further documentation
109
110 See [doc/README.md](doc/README.md) for more detailed end-user documentation.
111
112 See [CONTRIBUTING.md](CONTRIBUTING.md) for contribution documentation.
113
114 See [proto/README.md](proto/README.md) for a description of the profile.proto format.