platform_bionic/benchmarks/linker_relocation/README.md
Ryan Prichard 41f19708c8 Add a linker relocation benchmark
The benchmark creates a set of DSOs that mimic the work involved in
loading the current version of libandroid_servers.so. The synthetic
benchmark has roughly the same number of libraries with roughly the same
relocations.

Currently, on a local aosp_walleye build that includes recent performance
improvements (including the Neon-based CL
I3983bca1dddc9241bb70290ad3651d895f046660), using the "performance"
governor, the benchmark reports these scores:

$ adb shell taskset 10 \
  /data/benchmarktest64/linker-reloc-bench/linker-reloc-bench \
  --benchmark_repetitions=20 --benchmark_display_aggregates_only=true
...
--------------------------------------------------------------------------------
Benchmark                                      Time             CPU   Iterations
--------------------------------------------------------------------------------
BM_linker_relocation/real_time_mean        70048 us          465 us           20
BM_linker_relocation/real_time_median      70091 us          466 us           20
BM_linker_relocation/real_time_stddev        329 us         8.29 us           20

$ adb shell taskset 10 \
  /data/benchmarktest/linker-reloc-bench/linker-reloc-bench \
  --benchmark_repetitions=20 --benchmark_display_aggregates_only=true
...
--------------------------------------------------------------------------------
Benchmark                                      Time             CPU   Iterations
--------------------------------------------------------------------------------
BM_linker_relocation/real_time_mean        83051 us          462 us           20
BM_linker_relocation/real_time_median      83069 us          464 us           20
BM_linker_relocation/real_time_stddev        184 us         8.91 us           20

Test: manual
Bug: none
Change-Id: I6dac66978f8666f95c76387093bda6be0151bfce
2020-01-14 13:12:56 -08:00

1 KiB

Dynamic Linker Relocation Benchmark

This benchmark measures the time spent in the dynamic linker to load a large set of shared objects with many symbols and relocations. It mimics the work involved in loading a fixed version of libandroid_servers.so.

Running the benchmark

To run the benchmark, build the linker-reloc-bench target, sync data, and run the benchmark from /data/benchmarktest[64]/linker-reloc-bench.

There is also a run_bench_with_ninja.sh script that uses the gen_bench.py --ninja mode to generate a benchmark. It's useful for experimentation. The --cc and --linker flags allow swapping out different static and dynamic linkers.

Regenerating the synthetic benchmark

regen/dump_relocs.py scans an ELF file and its dependencies, outputting a JSON dump, then regen/gen_bench.py processes the JSON file into benchmark code. gen_bench.py has two modes:

  • (default) generate Android.bp and source files
  • with --ninja: generate a build.ninja instead, and build a set of ELF file outputs