Skip to content
This repository was archived by the owner on Jul 31, 2023. It is now read-only.

Commit e5ad810

Browse files
authored
Update benchmarking docs. (#375)
1 parent ea4b63f commit e5ad810

1 file changed

Lines changed: 35 additions & 11 deletions

File tree

opencensus/doc/benchmarks.md

Lines changed: 35 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,20 +16,44 @@ library. This accepts several helpful flags, including
1616
benchmark_repetitions, report only summary statistics and not single-run
1717
timings.
1818

19+
Don't forget to use `-c opt` to get an optimized build.
20+
1921
## Profiling
2022

2123
Benchmarks can be profiled using the
22-
[gperftools](https://github.com/gperftools/gperftools) library. On
23-
Debian/Ubuntu, install the `google-perftools` (profile analysis tools) and
24-
`libgoogle-perftools-dev` (profiling library) packages. When running the
25-
benchmark, set `LD_PRELOAD=/usr/lib/libprofiler.so` to enable the profiler and
26-
`CPUPROFILE=PATH` to save a profile, and analyze the profile with
27-
`google-pprof` (which needs a path to the binary for symbolization). For
28-
example,
24+
[gperftools](https://github.com/gperftools/gperftools) library. To install on
25+
Debian / Ubuntu:
26+
27+
```shell
28+
sudo apt install google-perftools libgoogle-perftools-dev
29+
```
30+
31+
When running the benchmark, set:
32+
- `LD_PRELOAD=/usr/lib/x86_64-linux-gnu/libprofiler.so.0` to enable the
33+
profiler.
34+
- `CPUPROFILE=path_to_output_file`
35+
- Optional: `CPUPROFILE_FREQUENCY=4000` to increase resolution.
36+
- Optional: for visibility into inlined functions, build with `-g1` or above.
37+
38+
Analyze the profile with `google-pprof`, which needs a path to the binary for
39+
symbolization.
40+
41+
Example:
42+
2943
```shell
30-
bazel build -c opt opencensus/stats:stats_manager_benchmark
31-
LD_PRELOAD=/usr/lib/libprofiler.so CPUPROFILE=/tmp/prof \
32-
./bazel-bin/opencensus/stats/stats_manager_benchmark
44+
bazel build -c opt --copt=-g1 opencensus/stats:stats_manager_benchmark
45+
LD_PRELOAD=/usr/lib/x86_64-linux-gnu/libprofiler.so.0 \
46+
CPUPROFILE=/tmp/prof \
47+
CPUPROFILE_FREQUENCY=4000 \
48+
./bazel-bin/opencensus/stats/stats_manager_benchmark
3349
google-pprof --web bazel-bin/opencensus/stats/stats_manager_benchmark /tmp/prof
3450
```
35-
pprof supports many analysis types--see its documentation for options.
51+
52+
`google-pprof` supports many analysis types - see its
53+
[documentation](https://gperftools.github.io/gperftools/cpuprofile.html) for
54+
options.
55+
56+
Note that `CPUPROFILE_FREQUENCY` defaults to 100 samples per second.
57+
The maximum value `libprofiler` will accept is 4000.
58+
Most Linux kernels are built with `CONFIG_HZ=250`, so a single-threaded
59+
benchmark will produce at most 250 samples per second.

0 commit comments

Comments
 (0)