Page MenuHomePhabricator

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

Authored by majcosta on Wed, Jul 29, 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
Automatic diff as part of commit; lint not applicable.
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

majcosta created this revision.Wed, Jul 29, 17:17
Herald added a reviewer: Restricted Project. · View Herald TranscriptWed, Jul 29, 17:17
majcosta requested review of this revision.Wed, Jul 29, 17:17
majcosta edited the summary of this revision. (Show Details)Wed, Jul 29, 17:32
Fabien accepted this revision.Wed, Jul 29, 20:58
This revision is now accepted and ready to land.Wed, Jul 29, 20:58