nanobench: fix performance counter buffer initialization #35607

pull l0rinc wants to merge 1 commits into bitcoin:master from l0rinc:l0rinc/perf-counters changing 1 files +3 −3
  1. l0rinc commented at 12:08 AM on June 26, 2026: contributor

    Problem: The Linux perf counter buffers are documented as starting with three read_format metadata slots, but std::vector<uint64_t>{3} creates a one-element vector containing 3. In normal benchmark runs this is usually hidden because successful monitor() calls resize the buffers before updateResults(), while failed setup sets mHasError before the indexed reads.

    Fix: Use the vector size constructor so the buffers start with three zero-initialized metadata slots. This should not change the usual successful benchmark path, but it makes the default object state match the code's indexing assumptions.

    Reproducer: https://godbolt.org/z/scE8rMd8Y Upstream: https://github.com/martinus/nanobench/pull/138

  2. nanobench: fix perf counter buffer init
    The perf counter read buffer comment says the vectors start with three metadata slots, but brace initialization creates one element with value 3.
    Normal benchmark construction usually hides this because successful `monitor()` calls resize the buffers before `updateResults()`, while failed setup sets `mHasError` before the indexed reads.
    Initialize the vectors with the size constructor so a default-constructed `LinuxPerformanceCounters` object satisfies the `read_format` invariant instead of relying on that construction path.
    Reproducer: https://godbolt.org/z/scE8rMd8Y
    b6b1d0653a
  3. DrahtBot commented at 12:08 AM on June 26, 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/35607.

    <!--021abf342d371248e50ceaed478a90ca-->

    Reviews

    See the guideline for information on the review process.

    Type Reviewers
    ACK dergoegge, sedited

    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. dergoegge approved
  5. dergoegge commented at 1:26 PM on July 1, 2026: member

    Code review ACK b6b1d0653af18dfff752c03381c9f58e11b83130

    This is trivial, and also kind of pointless, because the buffer are always resized appropriately anyway, but the code change is fine.

  6. sedited approved
  7. sedited commented at 4:08 PM on July 1, 2026: contributor

    ACK b6b1d0653af18dfff752c03381c9f58e11b83130

  8. sedited merged this on Jul 1, 2026
  9. sedited closed this on Jul 1, 2026

  10. l0rinc deleted the branch on Jul 1, 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-07-04 02:51 UTC

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