[RFC] rpc: expose locked-memory arena_count from getmemoryinfo #35411

pull HowHsu wants to merge 1 commits into bitcoin:master from HowHsu:arena_count changing 5 files +8 −1
  1. HowHsu commented at 11:32 AM on May 29, 2026: contributor

    First of all, this is caused by the TODO comment below, just put this PR here to ask some questions about this TODO since I'm not very familiar with all the use pattern of lockedpool: From AI analysis, the arena.size() is related with the number of wallets, and 10000 wallets causes about 10 arenas, is this a real production scenario in practice? Do we really has to keep this TODO there?

        // TODO we can do better than this linear search by keeping a map
        // of arena extents to arena, and looking up the address.
    
    

    Mirror the existing chunks_used / chunks_free fields by adding a sibling arena_count field that exposes LockedPool's arenas.size() directly. All three are internal implementation details of the secure-memory pool surfaced to operators and diagnostic tooling.

    Beyond observability, arena_count is also performance-relevant. As the existing TODO in LockedPool::free() points out:

    // TODO we can do better than this linear search by keeping a map
    // of arena extents to arena, and looking up the address.

    LockedPool::free() walks the arena list linearly on every secure deallocation. While this is fine for the common case of a single arena, the cost scales with arena count. Exposing arena_count gives operators and developers a way to see when the pool has grown past that hot path's sweet spot, without having to estimate it from total / ARENA_SIZE (which is wrong when the first arena is capped by RLIMIT_MEMLOCK and misleading when memory is fragmented).

    Includes unit-test coverage in allocator_tests (mock pool, before and after multi-arena allocation) and a functional-test assertion in rpc_misc.py.

  2. rpc: expose locked-memory arena_count from getmemoryinfo
    Mirror the existing chunks_used / chunks_free fields by adding a
    sibling arena_count field that exposes LockedPool's arenas.size()
    directly. All three are internal implementation details of the
    secure-memory pool surfaced to operators and diagnostic tooling.
    
    Beyond observability, arena_count is also performance-relevant. As
    the existing TODO in LockedPool::free() points out:
    
        // TODO we can do better than this linear search by keeping a map
        // of arena extents to arena, and looking up the address.
    
    LockedPool::free() walks the arena list linearly on every secure
    deallocation. While this is fine for the common case of a single
    arena, the cost scales with arena count. Exposing arena_count gives
    operators and developers a way to see when the pool has grown past
    that hot path's sweet spot, without having to estimate it from
    total / ARENA_SIZE (which is wrong when the first arena is capped by
    RLIMIT_MEMLOCK and misleading when memory is fragmented).
    
    Includes unit-test coverage in allocator_tests (mock pool, before and
    after multi-arena allocation) and a functional-test assertion in
    rpc_misc.py.
    2bf19baf99
  3. DrahtBot commented at 11:32 AM on May 29, 2026: 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/35411.

    <!--021abf342d371248e50ceaed478a90ca-->

    Reviews

    See the guideline for information on the review process.

    Type Reviewers
    Concept NACK l0rinc

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

    <!--5faf32d7da4f0f540f40219e4f7537a3-->

  4. stickies-v commented at 2:05 PM on May 29, 2026: contributor

    Do you have a specific use case that would need arena_count to be exposed in the RPC? If so, that would be useful to add to the OP.

  5. HowHsu commented at 2:43 PM on May 29, 2026: contributor

    Do you have a specific use case that would need arena_count to be exposed in the RPC? If so, that would be useful to add to the OP.

    When users encounter performance issues with their Bitcoin Core node, one possible root cause could be the arena_count, since freeing memory is O(arena_count). Exposing this information through the RPC would allow users to include it in bug reports, making it easier for the developer community to diagnose and resolve such issues.

  6. l0rinc commented at 11:12 AM on May 31, 2026: contributor

    NACK, the author doesn't understand the change, it just seems like busy work.


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-05-31 17:50 UTC

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