bench: add and use undo-data for BlockToJsonVerbosity3 bench #36254

pull 0xB10C wants to merge 1 commits into bitcoin:master from 0xB10C:2026-09-fix-bench-getblock-v3 changing 3 files +21 −0
  1. 0xB10C commented at 7:56 PM on September 14, 2026: contributor

    blockToJSON only includes prevouts and fees when we have undo-data. The benchmarks did not have any undo-data, so TxVerbosity::SHOW_DETAILS and TxVerbosity::SHOW_DETAILS_AND_PREVOUT did exactly the same work.

    This adds the 136 KB of undo-data of block 413567 and uses it in the benchmarks.

    $ ./build/bin/bench_bitcoin --filter=BlockToJson.* -min-time=5000
    

    Before:

    ns/op op/s err% total benchmark
    10,273,470.25 97.34 0.2% 5.51 BlockToJsonVerboseWrite
    104,973.68 9,526.20 0.1% 5.51 BlockToJsonVerbosity1
    17,071,753.65 58.58 0.1% 5.52 BlockToJsonVerbosity2
    17,256,754.10 57.95 0.1% 5.51 BlockToJsonVerbosity3

    Note that the BlockToJsonVerbosity2 and BlockToJsonVerbosity3 times were the same.

    After:

    ns/op op/s err% total benchmark
    16,207,066.75 61.70 0.7% 5.45 BlockToJsonVerboseWrite
    109,119.99 9,164.22 0.4% 5.59 BlockToJsonVerbosity1
    17,907,169.45 55.84 0.1% 5.49 BlockToJsonVerbosity2
    34,274,126.50 29.18 0.1% 5.30 BlockToJsonVerbosity3
    • BlockToJsonVerboseWrite: slower as it now also writes the prevouts too
    • BlockToJsonVerbosity1: unchanged
    • BlockToJsonVerbosity2: slightly slower as we now read the undo-data and calculate the fee field
    • BlockToJsonVerbosity3: slower as it's using undo-data now
  2. DrahtBot added the label Tests on Sep 14, 2026
  3. DrahtBot commented at 7:57 PM on September 14, 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/36254.

    <!--021abf342d371248e50ceaed478a90ca-->

    Reviews

    See the guideline and AI policy for information on the review process.

    Type Reviewers
    ACK ismaelsadeeq

    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. DrahtBot added the label CI failed on Sep 14, 2026
  5. DrahtBot commented at 8:58 PM on September 14, 2026: contributor

    <!--85328a0da195eb286784d51f73fa0af9-->

    🚧 At least one of the CI tasks failed. <sub>Task iwyu: https://github.com/bitcoin/bitcoin/actions/runs/34889958781/job/104129847496</sub> <sub>LLM reason (✨ experimental): CI failed because IWYU detected include issues (“^^^ ⚠️ Failure generated from IWYU”) and exited with a non-zero status.</sub>

    <details><summary>Hints</summary>

    Try to run the tests locally, according to the documentation. However, a CI failure may still happen due to a number of reasons, for example:

    • Possibly due to a silent merge conflict (the changes in this pull request being incompatible with the current code in the target branch). If so, make sure to rebase on the latest commit of the target branch.

    • A sanitizer issue, which can only be found by compiling with the sanitizer and running the affected test.

    • An intermittent issue.

    Leave a comment here, if you need help tracking down a confusing failure.

    </details>

  6. bench: add undo-data for BlockToJsonVerbosity3
    blockToJSON only includes prevouts and fees when we have undo-data.
    The benchmarks did not have any undo-data, so TxVerbosity::SHOW_DETAILS
    and TxVerbosity::SHOW_DETAILS_AND_PREVOUT did exactly the same work.
    
    This adds the 139KB of undo-data of block 413567 and uses it in the
    benchmarks.
    
    ```
    $ ./build/bin/bench_bitcoin --filter=BlockToJson.* -min-time=5000
    ```
    
    Before:
    
    |               ns/op |                op/s |    err% |     total | benchmark
    |--------------------:|--------------------:|--------:|----------:|:----------
    |       10,273,470.25 |               97.34 |    0.2% |      5.51 | `BlockToJsonVerboseWrite`
    |          104,973.68 |            9,526.20 |    0.1% |      5.51 | `BlockToJsonVerbosity1`
    |       17,071,753.65 |               58.58 |    0.1% |      5.52 | `BlockToJsonVerbosity2`
    |       17,256,754.10 |               57.95 |    0.1% |      5.51 | `BlockToJsonVerbosity3`  (same as Verbosity2 as undo-data is missing)
    
    After:
    
    |               ns/op |                op/s |    err% |     total | benchmark
    |--------------------:|--------------------:|--------:|----------:|:----------
    |       16,207,066.75 |               61.70 |    0.7% |      5.45 | `BlockToJsonVerboseWrite`
    |          109,119.99 |            9,164.22 |    0.4% |      5.59 | `BlockToJsonVerbosity1`
    |       17,907,169.45 |               55.84 |    0.1% |      5.49 | `BlockToJsonVerbosity2`
    |       34,274,126.50 |               29.18 |    0.1% |      5.30 | `BlockToJsonVerbosity3`
    
    - `BlockToJsonVerboseWrite`: slower as it now also writes the prevouts too
    - `BlockToJsonVerbosity1`: unchanged
    - `BlockToJsonVerbosity2`: slightly slower as we now read the undo-data and calculate the fee field
    - `BlockToJsonVerbosity3`: slower as it's using undo-data now
    0771dd89d6
  7. 0xB10C force-pushed on Sep 14, 2026
  8. DrahtBot removed the label CI failed on Sep 14, 2026
  9. ismaelsadeeq approved
  10. ismaelsadeeq commented at 9:13 AM on September 15, 2026: member

    Tested ACK 0771dd89d6eec31ea39f25b283aacbf2092c7c15

    I reproduced the benchmark and verified the undo-data blob.

    Metric Verbosity2 ins/op Verbosity3 ins/op
    before 326,698,108 326,688,650
    after 341,707,431 621,328,726
  11. 0xB10C commented at 7:23 PM on September 15, 2026: contributor

    As a side note:

    There's also the question how reliable a block from 10 years ago is for benchmarking BlockToJsonVerbosity3 today. The output types changed a lot and since we spend a lot of time on per-script work (address encoding, descriptor inference, checksums), the script type mix decides what the benchmark measures. With the old block, probably don't have good benchmark-coverage.

    We could add more recent blocks here, but not sure if that's worth the effort and repository size bloat. Maybe a crafted benchmark-block including P2PKH, P2SH, SegWit, Taproot, ... is an alternative. Or use @vostrnad's transaction for something like this.

    Still worth it to fix this benchmark now. Everything else can be a followup, if fast-ish verbose getblock is important to people.

  12. sedited commented at 9:54 PM on September 15, 2026: contributor

    We could add more recent blocks here, but not sure if that's worth the effort and repository size bloat. Maybe a crafted benchmark-block including P2PKH, P2SH, SegWit, Taproot, ... is an alternative.

    You might be interested in reviewing #32554 then.


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-09-23 13:51 UTC

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