Skip to content

Commit 8985412

Browse files
committed
Update documentation
1 parent e00c2a7 commit 8985412

File tree

1 file changed

+46
-4
lines changed

1 file changed

+46
-4
lines changed
Lines changed: 46 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,61 @@
1-
# Pprof
1+
---
2+
layout: default
3+
title: Pprof
4+
permalink: /testing-and-debugging/pprof
5+
---
26

3-
There is a built pprof server to faciliate profiling the program.
7+
## Pprof
8+
9+
There is a built-in pprof server to faciliate profiling the program.
10+
You can enable it with the flag `--pprofserver` or by modifying the TOML configuration file.
411

512
Note it does not affect performance unless the server is queried.
613

714
We assume Gossamer runs on `localhost` and the Pprof server is listening
8-
on the default `6060` port.
15+
on the default `6060` port. You can configure the Pprof server listening address with the pprof TOML key `listening-address` or the flag `--pprofaddress`.
916

1017
You need to have [Go](https://golang.org/dl/) installed to profile the program.
1118

19+
### Browser
20+
1221
The easiest way to visualize profiling data is through your browser.
1322

14-
The following commands are available and will show the result at [http://localhost:8000](http://localhost:8000):
23+
For example, the following commands will show interactive results at [http://localhost:8000](http://localhost:8000):
1524

1625
```sh
1726
# Check the heap
1827
go tool pprof -http=localhost:8000 http://localhost:6060/debug/pprof/heap
28+
# Check the CPU time spent for 10 seconds
29+
go tool pprof -http=localhost:8000 http://localhost:6060/debug/pprof/profile?seconds=10
1930
```
31+
32+
### Compare heaps
33+
34+
You can compare heaps with Go's pprof, this is especially useful to find memory leaks.
35+
36+
1. Download the first heap profile `wget -qO heap.1.out http://localhost:6060/debug/pprof/heap`
37+
1. Download the second heap profile `wget -qO heap.2.out http://localhost:6060/debug/pprof/heap`
38+
1. Compare the second heap profile with the first one using `go tool pprof -base ./heap.1.out heap.2.out`
39+
40+
### More routes
41+
42+
More routes are available in the HTTP pprof server. You can also list them at [http://localhost:6060/debug/pprof/](http://localhost:6060/debug/pprof/).
43+
Notable ones are written below:
44+
45+
#### Goroutine blocking profile
46+
47+
The route `/debug/pprof/block` is available but requires to set the block profile rate, using either the toml value `block-rate` or the flag `--pprofblockrate`.
48+
49+
#### Mutex contention profile
50+
51+
The route `/debug/pprof/mutex` is available but requires to set the mutex profile rate, using either the toml value `mutex-rate` or the flag `--pprofmutexrate`.
52+
53+
#### Other routes
54+
55+
The other routes are listed below, if you need them:
56+
57+
- `/debug/pprof/cmdline`
58+
- `/debug/pprof/symbol`
59+
- `/debug/pprof/trace`
60+
- `/debug/pprof/goroutine`
61+
- `/debug/pprof/threadcreate`

0 commit comments

Comments
 (0)