mirror of
https://github.com/bitcoin/bitcoin
synced 2026-12-04 10:50:37 +00:00
WIP: [RFC] enable clang-tidy optin.performance.Padding #36819
No reviewers
Labels
No labels
Android
Backport
Block storage
Brainstorming
Bug
Build system
CI failed
Consensus
Data corruption
Descriptors
Docs
DrahtBot Guix build requested
Feature
Fuzzing
GUI
Good First Review
IPC
Insufficient Review
Kernel
Linux/Unix
Mempool
Mining
Needs Backport (31.x)
Needs Backport (32.x)
Needs Benchmark
Needs Conceptual Review
Needs backport (30.x)
Needs rebase
Needs release note
Net
P2P
PSBT
Privacy
Private Broadcast
Questions and Help
RPC/REST/ZMQ
Refactoring
Resource usage
Review club
Scripts and tools
Settings
TX fees and policy
Tests
Tracking Issue
UTXO Db and Indexes
Up for grabs
Upstream
Utils/log/libs
Validation
Waiting for author
Wallet
Windows
good first issue
interfaces
macOS
No milestone
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
bitcoin/bitcoin!36819
Loading…
Reference in a new issue
No description provided.
Delete branch "tidy_perf_padding"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Enable
optin.performance.Paddingwith the default of 24 bytes (made explicit in the clang-tidy config), after fixing warnings for more padding than that. Enabling it at this point would be to catch regressions above this amount.Based on #36501, which reorders
CBlockIndexto save 8 bytes (clang-tidyalso warns about this). Wondering if contributors/reviewers think this is worthwhile given we may make that refactor? Also not sure if it's possible for us to enable this generally, as padding will differ depending on various factors.The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.
External sites
Reviews
See the guideline and AI policy for information on the review process.
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:
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.
🔵 Suggestion · The fatal padding gate also constrains test fixtures and single-instance types
The tidy gate also constrains a five-element test fixture and node-wide single-instance objects, while an isolated 8-byte per-object regression remains below its threshold.
Location:
src/.clang-tidy:25(head).Review coverage was incomplete.
Reviewed:
2d1b3f97d9d5· Review report · Previous reportspermalink
Concept ACK, seems worthwhile to me.
Concept ACK, modulo keeping guarded members near their mutex and avoiding churn or grouping members less logically where it provides negligible benefit
Concept ACK, probably good to turn this on by default with a reasonable threshold.
For singleton types (
*Manetc), in cases where it really leads to less logical groupings of fields, one could opt out, like we do for recursion warnings today.🚧 At least one of the CI tasks failed.
Task
tidy: https://github.com/bitcoin/bitcoin/actions/runs/42668387091/job/129338067669LLM reason (✨ experimental): CI failed because clang-tidy flagged excessive struct padding in
ValidVectorintest/bip352_tests.cpp; warnings are treated as errors.Hints
Try to run the tests locally, according to the documentation. However, a CI failure may still
happen due to a number of reasons, for example:
Possibly due to a silent merge conflict (the changes in this pull request being
incompatible with the current code in the target branch). If so, make sure to rebase on the latest
commit of the target branch.
A sanitizer issue, which can only be found by compiling with the sanitizer and running the
affected test.
An intermittent issue.
Leave a comment here, if you need help tracking down a confusing failure.
Concept ACK for me too. I had not included other classes in the original PR because they are probably instantiated far less than 1 million times at once, so the changes seemed not worth it to me (sometimes members are ordered by fonctionality, code might be more understandable that way). But if there is now a CI check to avoid potentially losing more memory in the future, I'm all for it.
It seems the limit of 23 is not properly used though, since the CI output warns about a loss of 11 padding bytes?
Is this really worth it? This could make the code harder to read by having fields that belong together split further apart. See e.g. the mempool "rolling" section.
I'd say this should be an opt-in list for structs where we know they exist 1000s of times and that would benefit low-resource systems. E.g. saving 24kB on systems that have set 2000 connections (https://github.com/bitcoin/bitcoin/pull/35919), so likely they are not low-memory systems, seems a rounding error.
So my preference would be to have this opt-in per-struct and accommodate each change with a measurement, or at least a guess of how much it would save.
.
if memory usage was a concern here, those should be string_view
splitting this up makes the code harder to read for no benefit?
Not sure the tidy check makes sense (as @maflcko also mentioned, for classes with only a few instances in total, readability can matter more), but we could keep this open as a guide for similar changes, so we can consider them on a case-by-case basis.
🚧 At least one of the CI tasks failed.
Task
tidy: https://github.com/bitcoin/bitcoin/actions/runs/46029168189/job/140608243349LLM reason (✨ experimental): tidy_fail: clang-tidy reports excessive padding in
ValidVectorintest/bip352_tests.cpp, and warnings are treated as errors.Hints
Try to run the tests locally, according to the documentation. However, a CI failure may still
happen due to a number of reasons, for example:
Possibly due to a silent merge conflict (the changes in this pull request being
incompatible with the current code in the target branch). If so, make sure to rebase on the latest
commit of the target branch.
A sanitizer issue, which can only be found by compiling with the sanitizer and running the
affected test.
Intermittent network issues can occur; re-run CI for now, and report the issue if they keep happening.
A functional or integration test failure may be intermittent or unrelated to this pull request.
If no dedicated issue thread exists, create a new one to track it.
Leave a comment here, if you need help tracking down a confusing failure.