bench: use deterministic HexStr payload #34598

pull l0rinc wants to merge 1 commits into bitcoin:master from l0rinc:l0rinc/hexstr-bench changing 1 files +4 −2
  1. l0rinc commented at 11:38 am on February 16, 2026: contributor

    Context

    Split out of #32554 Inspired by #32457 (review)

    Problem

    HexStrBench uses the bytes from the embedded block fixture as a random source of bytes to measure HexStr performance against. This coupling makes block benchmark migrations in #32554 slightly more work than necessary.

    Fix

    We can use deterministic pseudo-random bytes instead so this benchmark keeps stable input without fixture coupling. Use MAX_BLOCK_WEIGHT so the benchmark stays in the same size range and keeps measured work above harness overhead. This changes the benchmark baseline because input size moves from about 1 MB to 4 MB.

  2. DrahtBot added the label Tests on Feb 16, 2026
  3. DrahtBot commented at 11:38 am on February 16, 2026: contributor

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

    Reviews

    See the guideline for information on the review process. A summary of reviews will appear here.

    Conflicts

    Reviewers, this pull request conflicts with the following ones:

    • #34448 (ci, iwyu: Fix warnings in src/util and treat them as errors by hebasto)
    • #32554 (bench: replace embedded raw block with configurable block generator by l0rinc)

    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.

  4. fanquake commented at 11:45 am on February 16, 2026: member

    Split out of #32554

    Is it currently necessary to split up what is already a single commit PR, into more commits and PRs? Looks like the status of #32554 is that it received review 5 days ago, that hasn’t been responded to.

  5. l0rinc force-pushed on Feb 16, 2026
  6. DrahtBot added the label CI failed on Feb 16, 2026
  7. l0rinc commented at 12:09 pm on February 16, 2026: contributor
    Yes, I’m working on that change currently, that’s why I’m splitting out commits from it that make sense on their own.
  8. l0rinc force-pushed on Feb 16, 2026
  9. bench: use deterministic `HexStr` payload
    `HexStrBench` uses the bytes from the embedded block fixture as a random source of bytes to measure `HexStr` performance against.
    This coupling makes block benchmark migrations slightly more work than necessary.
    
    We can use deterministic pseudo-random bytes instead so this benchmark keeps stable input without fixture coupling.
    Use `MAX_BLOCK_WEIGHT` so the benchmark stays in the same size range and keeps measured work above harness overhead.
    This changes the benchmark baseline because input size moves from about 1 MB to 4 MB.
    
    Co-authored-by: MarcoFalke <*~=`'#}+{/-|&$^_@721217.xyz>
    Co-authored-by: Hodlinator <172445034+hodlinator@users.noreply.github.com>
    353c660be5
  10. in src/bench/strencodings.cpp:16 in 4faec2c49f
    13 
    14 static void HexStrBench(benchmark::Bench& bench)
    15 {
    16-    auto const& data = benchmark::data::block413567;
    17+    FastRandomContext rng{/*fDeterministic=*/true};
    18+    auto data{rng.randbytes<std::byte>(CPubKey::COMPRESSED_SIZE)};
    


    maflcko commented at 12:19 pm on February 16, 2026:
    I don’t think the performance matters for short strings, as the other end-to-end overhead is larger. Why not just use the exact same size as before?

    l0rinc commented at 12:22 pm on February 16, 2026:

    While the exact size shouldn’t matter here, since HexStr is typically used with smaller objects, CPubKey::COMPRESSED_SIZE seems like a good enough fit here.

    It was deliberate. I don’t mind doing that, but as far as I can tell, it’s not representative.


    l0rinc commented at 1:03 pm on February 16, 2026:
    Changed it to MAX_BLOCK_WEIGHT as suggested by @hodlinator in https://github.com/bitcoin/bitcoin/pull/32554/changes#r2641304162
  11. l0rinc force-pushed on Feb 16, 2026
  12. DrahtBot removed the label CI failed on Feb 16, 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-02-17 06:13 UTC

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