Skip to content

Commit 6412279

Browse files
committed
pprof readme
Signed-off-by: Alec Holmes <[email protected]>
1 parent 337cf6b commit 6412279

File tree

4 files changed

+64
-23
lines changed

4 files changed

+64
-23
lines changed

Makefile

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
# Variables
55
#------------------------------------------------------------------------------
66

7-
SHELL := /bin/bash
8-
BINDIR := bin
7+
SHELL := /bin/bash
8+
BINDIR := bin
99
PKG := github.com/envoyproxy/go-control-plane
1010

1111
.PHONY: build
@@ -19,6 +19,7 @@ clean:
1919
@go mod tidy
2020
@rm -rf $(BINDIR)
2121
@rm -rf *.log
22+
@rm -rf *.pprof
2223

2324
# TODO(mattklein123): See the note in TestLinearConcurrentSetWatch() for why we set -parallel here
2425
# This should be removed.
@@ -74,10 +75,14 @@ integration.ads.delta: $(BINDIR)/test $(BINDIR)/upstream
7475
#------------------------------------------------------------------------------
7576
# Benchmarks utilizing intergration tests
7677
#------------------------------------------------------------------------------
77-
.PHONY: benchmark
78+
.PHONY: benchmark docker_benchmarks
7879
benchmark: $(BINDIR)/test $(BINDIR)/upstream
7980
env XDS=xds MODE=$(MODE) build/integration.sh
8081

82+
docker_benchmarks:
83+
docker build --pull -f Dockerfile.ci . -t gcp_ci && \
84+
docker run -v $$(pwd):/go-control-plane $$(tty -s && echo "-it" || echo) gcp_ci /bin/bash -c /go-control-plane/build/do_benchmarks.sh
85+
8186
#--------------------------------------
8287
#-- example xDS control plane server
8388
#--------------------------------------
@@ -93,7 +98,3 @@ example: $(BINDIR)/example
9398
docker_tests:
9499
docker build --pull -f Dockerfile.ci . -t gcp_ci && \
95100
docker run -v $$(pwd):/go-control-plane $$(tty -s && echo "-it" || echo) gcp_ci /bin/bash -c /go-control-plane/build/do_ci.sh
96-
97-
docker_benchmarks:
98-
docker build --pull -f Dockerfile.ci . -t gcp_ci && \
99-
docker run -v $$(pwd):/go-control-plane $$(tty -s && echo "-it" || echo) gcp_ci /bin/bash -c /go-control-plane/build/do_benchmarks.sh

benchmarks/README.md

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
# Benchmarks
2+
3+
These benchmarks are designed to run off the integration test suite, and provide detailed profiling artifacts generated with pprof.
4+
5+
## Prerequisites
6+
- [Go 1.16+](https://golang.org/dl/)
7+
- [Graphviz](https://graphviz.org/download/)
8+
- [pprof](https://github.com/google/pprof)
9+
- [Docker](https://www.docker.com/)
10+
11+
## Running Locally
12+
13+
To run the benchmarks locally, we take a similar apprach to the integration tests.
14+
15+
### Requirements
16+
17+
* Envoy binary `envoy` available: set `ENVOY` environment variable to the
18+
location of the binary, or use the default value `/usr/local/bin/envoy`
19+
* `go-control-plane` builds successfully
20+
* Local installation of pprof and graphviz for profiler output
21+
22+
### Steps
23+
24+
To run the benchmark:
25+
```
26+
make benchmark MODE=0
27+
```
28+
29+
There are 5 different modes all corresponding to various profiling outputs:
30+
```go
31+
const (
32+
PPROF_CPU int = iota
33+
PPROF_HEAP
34+
PPROF_MUTEX
35+
PPROF_BLOCK
36+
PPROF_GOROUTINE
37+
)
38+
```
39+
To specifiy the mode, use `MODE` environment variable that corresponds to the output you wish to evaluate.
40+
41+
## Running With Docker
42+
43+
To run the benchmarks, we just require the prerequisite of docker and go.
44+
45+
### Steps
46+
47+
To run the benchmarks:
48+
49+
```
50+
make docker_benchmarks
51+
```
52+
53+
This will generate all profile artifacts in the `./benchmarks/reports`. Graphical profile anaylsis is located in `/.benchmarks/pngs`.
54+
55+
For more information on how to interpret these reports/graphs, [click here](https://github.com/google/pprof/blob/master/doc/README.md#graphical-reports)

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ require (
88
github.com/envoyproxy/protoc-gen-validate v0.1.0
99
github.com/golang/protobuf v1.4.3
1010
github.com/google/go-cmp v0.5.0
11-
github.com/pkg/profile v1.6.0 // indirect
11+
github.com/pkg/profile v1.6.0
1212
github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4
1313
github.com/stretchr/testify v1.7.0
1414
go.opentelemetry.io/proto/otlp v0.7.0

pkg/test/main/README.md

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -37,18 +37,3 @@ eventually converges to use the latest pushed configuration) for each run.
3737

3838
You can run ```bin/test -help``` to get a list of the cli flags that
3939
the test program accepts. There are also comments in ```main.go```.
40-
41-
## Using the pprof profiler
42-
43-
One customization is to run the go language profiler [pprof](https://github.com/DataDog/go-profiler-notes/blob/main/pprof.md). See also <https://golang.org/pkg/runtime/pprof/>.
44-
45-
The profiler is normally off because it adds overhead to the tests. You can turn
46-
it on with the command line option `--pprof`. There is an environment variable
47-
`PPROF` for the `make` commands shown above. For example:
48-
49-
(export PPROF=true; make integration.xds)
50-
51-
The test will then write files of the form `block_profile_xds.pb.gz`. The files
52-
get written to the root of the project, in the same place as the envoy logs.
53-
54-
You can use `go tool pprof bin/test <file name>` to analyze the profile data.

0 commit comments

Comments
 (0)