mirror of
https://github.com/bitcoin/bitcoin
synced 2026-12-04 16:02:38 +00:00
WIP: improve MallocUsage and test in CI #36549
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!36549
Loading…
Reference in a new issue
No description provided.
Delete branch "202610_mallocusage"
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?
This is a WIP to improve the
MallocUsagefunction, with logic to measure actual usage in the unit test code.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.
A summary of reviews will appear here.
Conflicts
Reviewers, this pull request conflicts with the following ones:
[[noreturn]]by fanquake)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.
🚧 At least one of the CI tasks failed.
Task
macOS-cross to arm64: https://github.com/bitcoin/bitcoin/actions/runs/38850721587/job/116811104368LLM reason (✨ experimental): CI failed during compilation because
RandomSizesinmemusage_tests.cppis unused, and Clang treats that warning as an error.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.
Base:
924f4c4ac78b0cd3b917c694f42c0651a6f3003aHead:
6140d4c45155987c461b928ad9e94abf714208d6Findings
Major
Skip allocator-layout comparisons under Valgrind (src/test/memusage_tests.cpp:237, head)
The native Valgrind CI job runs this test under default Memcheck without enabling a compiler sanitizer, so
SANITIZER_ALLOCATORis false. Memcheck replaces the allocator, and its redzones change the small-block address gaps that this test compares against the glibc model. The mmap-threshold setting does not bypass that replacement. Skip this comparison under Valgrind or exclude the allocator-layout suite from that job while retaining native coverage.Minor
Include string terminators in allocation estimates (src/memusage.h:80, head)
The tighter rounding exposes a missing byte in
DynamicUsage(const std::string&), which still passescapacity()rather thancapacity() + 1for heap-backed strings. On 64-bit glibc, a non-SSO capacity of 24 is chargedMallocUsage(24) == 32, while the characters and terminator require at least 25 bytes, charged 48 by this model. The base formula returned 48, so this change introduces an undercount at that boundary. Buffered logging uses this estimate for memory-limit accounting, and symmetric insertion and removal do not correct the underestimated total. Passcapacity() + 1after the SSO check and add container-level boundary coverage. The behavior change is established, but no specific production message producing this boundary capacity was identified, so production impact is unconfirmed.Review coverage was incomplete. adversarial: The inspection limit prevented checking TxOrphanage::Announcement::GetMemUsage and its accounting/eviction paths; the effect of changed estimates on orphan-resource limits remains unverified. adversarial_glm: fill_mempool callers other than mempool_limit.py were not individually re-read; the IndexError reachability in finding 1 rests on the helper's documented -maxmempool=5 contract and on the fact that the pre-change code (fixed 72 batches, assert on eviction) already forces every current caller to use a ~5 MB pool, otherwise those tests would fail today. If any caller sets a larger pool, the failure mode would change from a failed assertion to an IndexError. adversarial_glm: The musl class-index formula (memusage.h:109-111) was verified by spot-checking representative slot values at each doubling boundary (including the extremes 161, 65520, 74880, 87360, 104832, 131055) rather than exhaustively; no out-of-bounds index is reachable since i<=44 before adjustment and i<=47 after. adversarial_glm: The COST/SLOT tables, the Windows LFH bucket sizes, and the macOS medium-range 8 MiB boundary are taken from the PR's stated measurements and cannot be confirmed statically. verifier: The supported FreeBSD test path and unconditional accuracy assertions were verified, but the native allocator layout needed to establish the claimed BSD failures was not independently verified. verifier: The musl COST constants, Windows LFH and VirtualAlloc accounting, and macOS 8 MiB medium-allocation boundary remain dependent on the supplied measurements. The musl lookup's index bounds and class-selection arithmetic were checked. verifier: Buffered logging was traced as a consumer of string accounting, but no specific production message was established to produce the capacity-24 trigger. verifier: Unresolved candidate: The checkout establishes the factual mismatch in scope: memusage.h retains an explicitly unmeasured historical estimate for BSDs, the new suite enforces narrow bounds without a platform exclusion, and doc/build-freebsd.md supports FreeBSD and recommends CTest. However, the claimed native address-gap values and resulting failures were not independently verified against allocator sources or measurements. Those are needed to publish the concrete supported-platform failure rather than merely request additional validation of an acknowledged limitation. ALL_SIZES is not itself the root cause, since random mode also enforces the same bounds; the separate runtime-cost objection has no established material regression beyond the supplied timing.
Full review report
🐙 This pull request conflicts with the target branch and needs rebase.