Skip to content

test: fix --perf profiling - #35509

Closed
theStack wants to merge 1 commit into
bitcoin:masterfrom
theStack:202606-test-fix_perf_profiling
Closed

theStack wants to merge 1 commit into
bitcoin:masterfrom
theStack:202606-test-fix_perf_profiling

Conversation

@theStack

@theStack theStack commented Jun 11, 2026 •

Copy link
Copy Markdown
Contributor

Functional test profiling with --perf (introduced in #14519) is currently broken, as TestNode._start_perf accesses the self.binary attribute which doesn't exist anymore since commit 0d2eefc / PR #31866. Fix that by using the proper field self.binaries.paths.bitcoind.

Also, perf's error output for missing kernel permissions changed slightly in 2020 (s/tweaking/adjusting) (see torvalds/linux@c1034eb), so adapt our matching string as well in order to show the "couldn't collect data" warning if necessary. Relying on a certain output string is obviously brittle, so we might want to do something smarter there.

This is a minimum-diff-fix that works on my machine (arm64, Ubuntu 25.04, Kernel 6.17.0-8-qcom-x1e, perf 6.1.174). I think the feature is useful in principle, but considering that no one noticed for more than a year that it's broken, it seems that no one really uses it, and an alternative might also be to remove it. Curious to hear opinions.

Functional test profiling with `--perf` (introduced in bitcoin#14519) is
currently broken, as `TestNode._start_perf` accesses the `self.binary`
attribute which doesn't exist anymore since commit
0d2eefc / PR bitcoin#31866. Fix that by using
the proper field `self.binaries.paths.bitcoind`.

Also, perf's error output for missing kernel permissions changed
slightly (s/tweaking/adjusting) [1], so adapt our matching string as well in
order to show the "couldn't collect data" warning if necessary.

[1] see torvalds/linux@c1034eb
@DrahtBot DrahtBot added the Tests label Jun 11, 2026
@DrahtBot

DrahtBot commented Jun 11, 2026 •

Copy link
Copy Markdown
Contributor

The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

Code Coverage & Benchmarks

For details see: https://corecheck.dev/bitcoin/bitcoin/pulls/35509.

Reviews

See the guideline for information on the review process.

Type Reviewers
Concept ACK w0xlt

If your review is incorrectly listed, please copy-paste <!--meta-tag:bot-skip--> into the comment that the bot should ignore.

Conflicts

Reviewers, this pull request conflicts with the following ones:

  • #35528 (test: doc: remove --perf profiling from functional test framework by theStack)

If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.

@w0xlt

w0xlt commented Jun 11, 2026

Copy link
Copy Markdown
Contributor

Concept ACK

@maflcko

maflcko commented Jun 11, 2026

Copy link
Copy Markdown
Member

Yeah, I think it can be removed (or moved to be doc-only), as it requires a manual diff anyway to make use of it, so that manual diff might as well just be a dedicated new functional test file with the test code, and a diff to test_node.py to force-inject perf.

The hints about compiling with debug symbols, the hint about dwarf/frame-pointers and the hint about perf_event_paranoid can be added to the docs instead.

Let's recall that we already have a micro-benchmark suite, so this is only meant for end-to-end performance testing that needs and expensive setup (like a specific blockchain, or txs generated with test utils). For end-to-end perf testing that only needs a trivial setup (like calling the echo RPC), a vanilla bash/Python script may be easier. One could even argue that one could use https://github.com/jamesob/verystable (or similar) in a vanilla script for more expensive setups, but I haven't tried this and I don't want to trail off too far.

@theStack

theStack commented Jun 11, 2026 •

Copy link
Copy Markdown
Contributor Author

@maflcko: Thanks for weighing in. I'm not opposed to removing it at all, but can you elaborate more on the "needing a manual diff" part? Is that referring to the usage with the profile_with_perf context manager? At least on my end when I invoke any functional test with the --perf flag, it seems to work out of the box with this PR (well, after installing perf and giving the kernel the needed permissions).

I'll keep the PR open for a few more days in any case, in the (seemingly unlikely?) case that anyone is strongly in favor of keeping it.

@maflcko

maflcko commented Jun 11, 2026

Copy link
Copy Markdown
Member

Is that referring to the usage with the profile_with_perf context manager? At least on my end when I invoke any functional test with the --perf flag, it seems to work out of the box with this PR

Ah, thx for correcting me. I've never used this feature and forgot.

@theStack

Copy link
Copy Markdown
Contributor Author

Opened #35528 as an alternative PR to remove it.

@w0xlt: I interpreted your "Concept ACK" as "makes sense to fix something broken" rather than a strong compelling reason to keep it, feel free to add more context in case you are e.g. using that feature regularly (or could see it being valuable).

fanquake added a commit that referenced this pull request Jun 15, 2026
…st framework

9fae7e9 test: doc: remove `--perf` profiling from functional test framework (Sebastian Falbesoner)

Pull request description:

  This PR is an alternative to #35509. Rather than fixing, it removes the `--perf` option / `profile_with_perf` context manager features (both introduced in #14519) from the functional test framework. Given that no developer apparently even noticed that it's been broken for more than a year, we can conclude that it's largely unused and getting rid of it to reduce maintenance burden seems a reasonable choice. So far, neither in #35509 nor [on IRC](https://bitcoin-irc.chaincode.com/bitcoin-core-dev/2026-06-12#1227556;) anyone has signaled strong interest to use or wanting to keep this feature.

  The corresponding test documentation is removed as well, though the mentioning of `perf` profiling is still kept in the general developer docs -- only the reference to functional test framework integration is removed there.

ACKs for top commit:
  l0rinc:
    lightweight code review ACK 9fae7e9
  maflcko:
    lgtm ACK 9fae7e9  While this seems useful, no one using it is a good reason to remove it. If a user comes after this is merged, it should be trivial to revert.

Tree-SHA512: cf7bdce72aed877c7dfa52a230840e0729e74b00f0c40c6ceecf04957707f4699f123c2cde5fc1c4ee21f4b1b14319c74acc78cd8066eab2b9a4d6efb4d11539
@theStack

Copy link
Copy Markdown
Contributor Author

Closing, since #35528 was merged.

@theStack theStack closed this Jun 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants