feat: create profiling package + rewrite profiling tutorial
Some checks reported warnings
Cadoles/bouncer/pipeline/head This commit was not built
Some checks reported warnings
Cadoles/bouncer/pipeline/head This commit was not built
This commit is contained in:
@ -1,31 +1,54 @@
|
||||
# Étudier les performances de Bouncer
|
||||
|
||||
1. Lancer un benchmark du proxy
|
||||
Le package `./internal` est dédié à l'étude des performances de Bouncer. Il contient une suite de benchmarks simulant de proxies avec différentes configurations de layers afin d'évaluer les points d'engorgement sur le traitement des requêtes.
|
||||
|
||||
```shell
|
||||
go test -bench=. -run '^$' -count=5 -cpuprofile bench_proxy.prof ./internal/proxy
|
||||
```
|
||||
Voir le répertoire `./internal/bench/testdata/proxies` pour voir les différentes configurations de cas.
|
||||
|
||||
2. Visualiser les temps d'exécution
|
||||
## Lancer les benchmarks
|
||||
|
||||
```shell
|
||||
go tool pprof -web bench_proxy.prof
|
||||
```
|
||||
Le plus simple est d'utiliser la commande `make bench` qui exécutera séquentiellement tous les benchmarks. Il est également possible de lancer un benchmark spécifique via la commande suivante:
|
||||
|
||||
3. Comparer les performances d'une exécution à l'autre
|
||||
```bash
|
||||
go test -bench="BenchmarkProxies/$BENCH_CASE" -run='^$' ./internal/bench
|
||||
```
|
||||
|
||||
```shell
|
||||
# Lancer un premier benchmark
|
||||
go test -bench=. -run '^$' -count=10 ./internal/proxy > bench_before.txt
|
||||
Par exemple:
|
||||
|
||||
# Faire des modifications sur les sources
|
||||
```bash
|
||||
# Pour exécuter ./internal/bench/testdata/proxies/basic-auth.yml
|
||||
go test -bench='BenchmarkProxies/basic-auth' -run='^$' ./internal/bench
|
||||
```
|
||||
|
||||
# Lancer un second benchmark
|
||||
go test -bench=. -run '^$' -count=10 ./internal/proxy > bench_after.txt
|
||||
## Visualiser les profils d'exécution
|
||||
|
||||
# Installer l'outil benchstat
|
||||
make tools/benchstat/bin/benchstat
|
||||
Vous pouvez visualiser les profils d'exécution via la commande suivante:
|
||||
|
||||
# Comparer les rapports
|
||||
tools/benchstat/bin/benchstat bench_before.txt bench_after.txt
|
||||
```
|
||||
```shell
|
||||
go tool pprof -web path/to/file.prof
|
||||
```
|
||||
|
||||
Par défaut l'exécution des benchmarks créera automatiquement des fichiers de profil dans le répertoire `./internal/bench/testdata/proxies`.
|
||||
|
||||
Par exemple:
|
||||
|
||||
```shell
|
||||
go tool pprof -web ./internal/bench/testdata/proxies/basic-auth.prof
|
||||
```
|
||||
|
||||
## Comparer les évolutions
|
||||
|
||||
```bash
|
||||
# Lancer un premier benchmark
|
||||
go test -bench="BenchmarkProxies/$BENCH_CASE" -run='^$' ./internal/bench
|
||||
|
||||
# Faire une sauvegarde du fichier de profil
|
||||
cp ./internal/bench/testdata/proxies/$BENCH_CASE.prof ./internal/bench/testdata/proxies/$BENCH_CASE-prev.prof
|
||||
|
||||
# Faire des modifications sur les sources
|
||||
|
||||
# Lancer un second benchmark
|
||||
go test -bench="BenchmarkProxies/$BENCH_CASE" -run='^$' ./internal/bench
|
||||
|
||||
# Visualiser la différence entre les deux profils
|
||||
go tool pprof -web -base=./internal/bench/testdata/proxies/$BENCH_CASE-prev.prof ./internal/bench/testdata/proxies/$BENCH_CASE.prof
|
||||
```
|
||||
|
Reference in New Issue
Block a user