refactor: remove dead branches in `SingletonClusterImpl` #33768

pull l0rinc wants to merge 1 commits into bitcoin:master from l0rinc:l0rinc/SingletonClusterImpl changing 1 files +7 −18
  1. l0rinc commented at 11:20 AM on November 3, 2025: contributor

    Found during review: cluster mempool: control/optimize TxGraph memory usage

    Fixes

    SplitAll() always calls ApplyRemovals() first, for a singleton, it empties the cluster, therefore any SingletonClusterImpl passed to Split() must be empty.

    TxGraphImpl::ApplyDependencies() first merges each dependency group and asserts the group has at least one dependency. Since parent != child, TxGraphImpl::Merge() upgrades the merge target to GenericClusterImpl, therefore the ApplyDependencies() is never dispatched to SingletonClusterImpl.

    Coverage proof:

  2. refactor: remove dead branches in `SingletonClusterImpl`
    `SplitAll()` always calls `ApplyRemovals()` first, for a singleton, it empties the cluster, therefore any `SingletonClusterImpl` passed to `Split()` must be empty.
    
    `TxGraphImpl::ApplyDependencies()` first merges each dependency group and asserts the group has at least one dependency.
    Since `parent` != `child`, `TxGraphImpl::Merge()` upgrades the merge target to `GenericClusterImpl`, therefore the `ApplyDependencies()` is never dispatched to `SingletonClusterImpl`.
    
    Found during review: https://github.com/bitcoin/bitcoin/pull/33157#discussion_r2423058928
    Coverage evidence:
    * https://maflcko.github.io/b-c-cov/fuzz.coverage/src/txgraph.cpp.gcov.html#L1446
    * https://storage.googleapis.com/oss-fuzz-coverage/bitcoin-core/reports/20251103/linux/src/bitcoin-core/src/txgraph.cpp.html#L1446
    2d23820ee1
  3. DrahtBot added the label Refactoring on Nov 3, 2025
  4. DrahtBot commented at 11:20 AM on November 3, 2025: contributor

    <!--e57a25ab6845829454e8d69fc972939a-->

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

    <!--006a51241073e994b41acfe9ec718e94-->

    Code Coverage & Benchmarks

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

    <!--021abf342d371248e50ceaed478a90ca-->

    Reviews

    See the guideline for information on the review process.

    Type Reviewers
    ACK sipa, instagibbs

    If your review is incorrectly listed, please react with 👎 to this comment and the bot will ignore it on the next update.

    <!--5faf32d7da4f0f540f40219e4f7537a3-->

  5. l0rinc marked this as ready for review on Nov 3, 2025
  6. sipa commented at 12:53 PM on November 3, 2025: member

    ACK 2d23820ee11678d567c75f94c40011ed9f0e274f

  7. fanquake requested review from instagibbs on Nov 3, 2025
  8. instagibbs commented at 11:57 AM on November 5, 2025: member

    ACK 2d23820ee11678d567c75f94c40011ed9f0e274f

  9. in src/txgraph.cpp:1442 in 2d23820ee1
    1447 | -        Updated(graph, level);
    1448 | -        return false;
    1449 | -    }
    1450 | +    Assume(!GetTxCount());
    1451 | +    graph.GetClusterSet(level).m_cluster_usage -= TotalMemoryUsage();
    1452 | +    return true;
    


    flack commented at 8:12 PM on November 6, 2025:

    this now always returns true. Is that needed for anything?


    l0rinc commented at 8:31 PM on November 6, 2025:

    Good question, I have already checked that, the sibling GenericClusterImpl::Split can return false which would trigger deletion.


    sipa commented at 8:36 PM on November 6, 2025:

    Yeah. It's indeed the case that within SingletonClusterImpl it'll always return true, but this isn't the case for all possible Cluster implementations.

  10. fanquake merged this on Nov 7, 2025
  11. fanquake closed this on Nov 7, 2025

  12. l0rinc deleted the branch on Nov 7, 2025
  13. l0rinc referenced this in commit e02714eb10 on Nov 7, 2025
  14. l0rinc referenced this in commit d6ce0ee916 on Nov 7, 2025
  15. l0rinc referenced this in commit 75919d5131 on Nov 7, 2025
  16. l0rinc referenced this in commit d834abacad on Nov 7, 2025
  17. sedited referenced this in commit 94f024ad07 on Nov 11, 2025
  18. l0rinc referenced this in commit b69f29f31d on Nov 11, 2025
  19. l0rinc referenced this in commit ee34564193 on Nov 11, 2025
  20. yuvicc referenced this in commit f620a2206b on Nov 16, 2025
  21. stringintech referenced this in commit 52fffa1e5d on Nov 24, 2025
  22. achow101 referenced this in commit b26762bdcb on Dec 10, 2025
  23. stickies-v referenced this in commit 9fa736f8e4 on Jan 22, 2026
  24. Kino1994 referenced this in commit 3f94262233 on Jun 28, 2026
  25. BigcoinBGC referenced this in commit ea80b60b5e on Jun 30, 2026
  26. Kino1994 referenced this in commit 0210e9f37f on Aug 19, 2026
  27. bitcoin locked this on Nov 7, 2026

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-11-20 15:51 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me