Skip to content

Commit 1e1267a

Browse files
eh-ampetethepig
andauthored
Benchmark dashboard (#349)
* benchmark: generate new benchmark dashboard * benchmark: fix missing metrics * dashboard: update the grafana example to point to the jsonnet dash * clean up * benchmark: prepend metrics with _benchmark and use gauge for progress * benchmark: continue to display progress pane after execution is finished Co-authored-by: Dmitry Filimonov <dmitry@pyroscope.io>
1 parent de87046 commit 1e1267a

File tree

14 files changed

+3088
-559
lines changed

14 files changed

+3088
-559
lines changed

benchmark/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,6 @@ Edit `run-parameters.env` file to change the parameters of the benchmark run.
3232

3333
## Browsing results
3434

35-
To view results open [http://localhost:8080/d/65gjqY3Mk/main?orgId=1](http://localhost:8080/d/65gjqY3Mk/main?orgId=1).
35+
To view results open [http://localhost:8080/d/tsWRL6ReZQkirFirmyvnWX1akHXJeHT8I8emjGJo/main?orgId=1](http://localhost:8080/d/tsWRL6ReZQkirFirmyvnWX1akHXJeHT8I8emjGJo/main?orgId=1).
3636

3737
You will also be able to see screenshots of the runs in `./runs` directory

benchmark/docker-compose.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ services:
4040
volumes:
4141
- ./grafana-provisioning:/etc/grafana/provisioning
4242
- ./grafana/grafana.ini:/etc/grafana/grafana.ini
43+
- ../monitoring/gen/benchmark-dashboard.json:/etc/grafana/provisioning/dashboards/benchmark-dashboard.json
4344
ports:
4445
- 8080:3000
4546

benchmark/grafana-provisioning/datasources/prometheus.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
datasources:
3-
- name: Prometheus
3+
- name: prometheus
44
# <string, required> datasource type. Required
55
type: prometheus
66
# <string, required> access mode. proxy or direct (Server or Browser in the UI). Required

benchmark/main.go

Lines changed: 18 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ func waitUntilEndpointReady(url string) {
5151
}
5252
}
5353

54-
func startClientThread(appName string, wg *sync.WaitGroup, appFixtures []*transporttrie.Trie, runProgress prometheus.Gauge) {
54+
func startClientThread(appName string, wg *sync.WaitGroup, appFixtures []*transporttrie.Trie, runProgress prometheus.Gauge, successfulUploads prometheus.Counter, uploadErrors prometheus.Counter) {
5555
rc := remote.RemoteConfig{
5656
UpstreamThreads: 1,
5757
UpstreamAddress: "http://pyroscope:4040",
@@ -69,17 +69,6 @@ func startClientThread(appName string, wg *sync.WaitGroup, appFixtures []*transp
6969

7070
st := threadStartTime
7171

72-
reg := prometheus.NewRegistry()
73-
74-
uploadErrors := promauto.With(reg).NewCounter(prometheus.CounterOpts{
75-
Name: "pyroscope_upload_errors",
76-
Help: "",
77-
})
78-
successfulUploads := promauto.With(reg).NewCounter(prometheus.CounterOpts{
79-
Name: "pyroscope_successful_uploads",
80-
Help: "",
81-
})
82-
8372
for i := 0; i < requestsCount; i++ {
8473
t := appFixtures[i%len(appFixtures)]
8574

@@ -205,16 +194,25 @@ func main() {
205194

206195
logrus.Info("waiting for other services to load")
207196

208-
benchmark := promauto.NewGauge(prometheus.GaugeOpts{
209-
Name: "pyroscope_benchmark",
210-
Help: "",
211-
})
212197
runProgress := promauto.NewGauge(prometheus.GaugeOpts{
213-
Name: "pyroscope_run_progress",
214-
Help: "",
198+
Namespace: "pyroscope",
199+
Subsystem: "benchmark",
200+
Name: "progress",
201+
Help: "",
215202
})
216203

217-
benchmark.Set(0)
204+
uploadErrors := promauto.NewCounter(prometheus.CounterOpts{
205+
Namespace: "pyroscope",
206+
Subsystem: "benchmark",
207+
Name: "upload_errors",
208+
Help: "",
209+
})
210+
successfulUploads := promauto.NewCounter(prometheus.CounterOpts{
211+
Namespace: "pyroscope",
212+
Subsystem: "benchmark",
213+
Name: "successful_uploads",
214+
Help: "",
215+
})
218216

219217
waitUntilEndpointReady("pyroscope:4040")
220218
waitUntilEndpointReady("prometheus:9090")
@@ -239,7 +237,6 @@ func main() {
239237
logrus.Info("done generating fixtures")
240238

241239
logrus.Info("starting sending requests")
242-
benchmark.Set(1)
243240
startTime := time.Now()
244241
reportSummaryMetric("start-time", startTime.Format(timeFmt))
245242
wg := sync.WaitGroup{}
@@ -249,12 +246,11 @@ func main() {
249246
for i := 0; i < appsCount; i++ {
250247
r.Read(appNameBuf)
251248
for j := 0; j < clientsCount; j++ {
252-
go startClientThread(hex.EncodeToString(appNameBuf), &wg, fixtures[i], runProgress)
249+
go startClientThread(hex.EncodeToString(appNameBuf), &wg, fixtures[i], runProgress, successfulUploads, uploadErrors)
253250
}
254251
}
255252
wg.Wait()
256253
logrus.Info("done sending requests")
257-
benchmark.Set(0)
258254
reportSummaryMetric("stop-time", time.Now().Format(timeFmt))
259255
reportSummaryMetric("duration", time.Since(startTime).String())
260256

benchmark/start.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ echo "building containers..."
88

99
source ./run-parameters.env
1010
export PYROSCOPE_CPUS PYROSCOPE_MEMORY
11+
export DOCKER_BUILDKIT=1
1112

1213
docker-compose build
1314

examples/grafana-integration/docker-compose.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ services:
1010
image: grafana/grafana:8.1.1
1111
volumes:
1212
- ./grafana-provisioning:/etc/grafana/provisioning
13+
- ../../monitoring/gen/dashboard.json:/etc/grafana/provisioning/dashboards/dashboard.json
1314
- ./grafana/grafana.ini:/etc/grafana/grafana.ini
1415
- ./grafana/home.json:/default-dashboard.json
1516
environment:

monitoring/Makefile

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
1+
all: dashboard benchmark-dashboard
2+
13
dashboard:
2-
jsonnet -J vendor dashboard.jsonnet | tee dashboard.json
4+
jsonnet -J vendor dashboard.jsonnet | tee gen/dashboard.json
5+
6+
benchmark-dashboard:
7+
jsonnet -J vendor benchmark.jsonnet | tee gen/benchmark-dashboard.json
38

49
.PHONY: init
510
init:

monitoring/README.md

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
77
make init
88
```
99

10-
3. (Re)Generate the dashboard
10+
3. (Re)Generate the dashboards
1111
```
12-
make dashboard
12+
make
1313
```
1414

1515
# Development
@@ -18,11 +18,12 @@ make dashboard
1818
Run the [grafana-integration](../examples/grafana-integration) example docker-compose then copy the generated dashboard there:
1919

2020
```
21-
make dashboard && \
22-
cp dashboard.json ../examples/grafana-integration/grafana-provisioning/dashboards/ && \
23-
docker-compose -f ../examples/grafana-integration/docker-compose.yml up -d --force-recreate grafana
21+
make && docker-compose -f ../examples/grafana-integration/docker-compose.yml up -d --force-recreate grafana
2422
```
2523

24+
# Warnings
25+
* If you ever rename the dashboard path, don't forget to update the references (see all the docker-compose.yaml)
26+
2627
# References
2728

2829
* https://grafana.github.io/grafonnet-lib/api-docs/

monitoring/benchmark.jsonnet

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
local config = import 'config.libsonnet';
2+
local dashboard = import './lib/dashboard.libsonnet';
3+
4+
(config + dashboard + {
5+
_config+:: {
6+
benchmark: true,
7+
}
8+
}).dashboard

monitoring/config.libsonnet

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
_config+:: {
3+
selector: 'instance="$instance"',
4+
// whether to add additional benchmark fields or not
5+
benchmark: false,
6+
}
7+
}

0 commit comments

Comments
 (0)