#36234 util: avoid redundant rolling Bloom insertions

ReviewabilityReviewsAgreementSize
#36234 JeremyRubin util: avoid redundant rolling Bloom insertionsReady0Crickets22 + 52 tests
  • Prevent rolling Bloom filters from prematurely expiring unrelated entries when duplicate items are inserted
  • Preserve configured capacity guarantees when items are announced repeatedly
  • Ready for review
  • No review verdicts recorded
  • No substantive reviews yet
  • Asked whether this targets worrying real-world usage patterns or general correctness (instagibbs)
  • Author demonstrated that repeated announcements can trivially wipe the known-transaction filter
  • 22 lines added or modified outside tests
  • 52 lines added or modified in tests
  • 3 lines removed in total
  • 3 files, 1 commits
Utilities (logging, arguments, libraries)#21 of 59
P3 · bug fix
  • P3 because repeated insertions prematurely rotate the filter and expire unrelated entries before capacity
  • Fixes an edge case where duplicate entries degrade filter retention guarantees
  • Ranking pass: Moved up: premature rotation breaks the capacity guarantee of a widely used primitive.
Reviewability: ReadyStalePaused
Agreement: StrongPositivePositive w/ caveatsNeutralMildDisputedBlockedCrickets
Reviews: current code-review ACKs, then (+stale ACKs) and -NACKs; greener = more ACKs.
Size: lines added or modified outside tests, then in tests; greener = smaller.

Goal

Skip advancing generation counters and rotating when re-inserting an element already present in the current generation of a CRollingBloomFilter. Computed hash values are cached in a stack array during the membership check so insertion does not recompute them.

Problem: Inserting the same item repeatedly increments the generation entry counter without adding new membership data. This causes the rolling filter to rotate generations prematurely, expiring older, unrelated entries earlier than its configured capacity guarantees.

Evidence of importance:

  • PR description: "Re-inserting a value already represented by the current generation advances its entry counter without adding membership information. Repeating one value can therefore expire unrelated entries sooner than the configured capacity implies."

Reviewability

Ready

Nothing known that would invalidate a review now.

Waiting on (from the thread read):

  • reviewer: review of author's reply and demonstration 2026-10-22
  • reviewer: review of the author's reply and demonstration 2026-10-22

Agreement

Crickets

no substantive comment either way

Thread notes: Recorded instagibbs' question about real-world usage patterns, which was answered by author JeremyRubin with a reproduction script showing filter wiping. / Added instagibbs's question and recorded the author's reply showing a test case demonstrating filter wiping.

Objections, suggestions, and questions:

ReviewerTypeHarm, request, or questionStatusMust beAuthor repliedQuote
instagibbs (member)question, usefulnessWhether there are worrying usage patterns seen in practice that this resolves, or if it is a general correctness issue noticedanswered · author replied demonstrating how repeated announcements can wipe the known-tx filteransweredyes2026-09-14: 'Are there any worrying usage patterns that you've seen this resolves, or is this more of a general correctness issue that was noticed?'
Status from: 2026-10-22: JeremyRubin: 'Yes, this allows for somewhat trivially wiping the known-tx filter.'

Participants:

  • instagibbs (member, question, 1 statements 2026-09-14 to 2026-09-14): asked whether this resolves worrying usage patterns seen in practice or is a general correctness fix

Files

52 lines under test/bench/ci.

  • src/test/bloom_tests.cpp +52/-0
  • src/common/bloom.cpp +20/-3
  • src/common/bloom.h +2/-0

Card

The short text the ranking pass compares across PRs.

CRollingBloomFilter is modified to detect whether an inserted element is already represented in the current generation, avoiding redundant entry counter increments and filter rotations. Currently, repeatedly inserting the same value advances generations and purges unrelated entries prematurely. Re-inserting elements from older generations continues to consume capacity and refresh their retention.

Data

dossier JSON · extract JSON · model ledger, generated 2026-10-23T01:16, confidence high, input hash d7e97f891e2b0e9e
thread read through 2026-10-22 (2 statements), head 25ce2fa1f6
labels: Utils/log/libs

Categories

Utilities (logging, arguments, libraries)

P3 · bug fix (ranking pass: Moved up: premature rotation breaks the capacity guarantee of a widely used primitive.)

Prevents CRollingBloomFilter from rotating generations prematurely when duplicate items are inserted. As described, 'Re-inserting a value already represented by the current generation advances its entry counter without adding membership information,' causing earlier expiration of unrelated entries than configured.

Membership: Matches the Utils/log/libs label and changes CRollingBloomFilter implementation in src/common/bloom.cpp.

Factors: security/stability 1, bug 1, performance 1, user value 0, leverage 0