Page MenuHomePhabricator

[backport#14519] tests: add utility to easily profile node performance with perf

Authored by majcosta on Jul 29 2020, 17:17.



docs: add perf section to developer docs (James O'Beirne)
add utility to easily profile node performance with perf (James O'Beirne)

Pull request description:

Adds a context manager to easily (and selectively) profile node performance during functional test execution using `perf`.

While writing some tests, I encountered some odd bitcoind slowness. I wrote up a utility (`TestNode.profile_with_perf`) that generates performance diagnostics for a node by running `perf` during the execution of a particular region of test code.

`perf` usage is detailed in the excellent (and sadly unmerged); all due props to @eklitzke.

### Example

with node.profile_with_perf("large-msgs"):
    for i in range(200):

This generates a perf data file in the test node's datadir (`/tmp/testtxmpod0y/node0/`).

Running `perf report` generates nice output about where the node spent most of its time while running that part of the test:

$ perf report -i /tmp/testtxmpod0y/node0/ --stdio \
  | c++filt \
  | less

Backport of Core PR14519

Test Plan
cd test
../../test/functional/ --perf --config=config.ini

run command to see test report in the output log

Diff Detail

rABC Bitcoin ABC
Lint Not Applicable
Tests Not Applicable