bench: Add benchmark to write JSON into a string #21170

pull martinus wants to merge 1 commits into bitcoin:master from martinus:2021-02-benchmark-BlockToJsonVerboseWrite changing 1 files +36 −12
  1. martinus commented at 9:23 am on February 13, 2021: contributor

    The benchmark BlockToJsonVerbose only tests generating (and destroying) the JSON data structure, but serializing into a string is also a performance critical aspect of the RPC calls.

    Extracts test setup into a struct TestBlockAndIndex, and uses it in both BlockToJsonVerbose and BlockToJsonVerboseWrite.

    Also, use ankerl::nanobench::doNotOptimizeAway to make sure the compiler can’t optimize the result of the calls away.

    Here are benchmark results on my Intel i7-8700:

    ns/op op/s err% ins/op cyc/op IPC bra/op miss% total benchmark
    71,807,017.00 13.93 0.4% 555,782,961.00 220,788,645.00 2.517 102,279,341.00 0.4% 0.80 BlockToJsonVerbose
    27,916,835.00 35.82 0.1% 235,084,034.00 89,033,525.00 2.640 42,911,139.00 0.3% 0.32 BlockToJsonVerboseWrite
  2. fanquake added the label Tests on Feb 13, 2021
  3. martinus force-pushed on Feb 13, 2021
  4. Add benchmark to write JSON into a string
    The benchmark BlockToJsonVerbose only tests generating (and destroying)
    the JSON data structure, but serializing into a string is also a
    performance critical aspect of the RPC calls.
    
    Also, use ankerl::nanobench::doNotOptimizeAway to make sure the compiler
    can't optimize the result of the calls away.
    e3e0a2432c
  5. martinus force-pushed on Feb 13, 2021
  6. DrahtBot commented at 6:07 pm on February 13, 2021: member

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

    Conflicts

    Reviewers, this pull request conflicts with the following ones:

    • #21245 (rpc: Add level 3 verbosity to getblock RPC call. by fyquah)
    • #21003 (test: Move MakeNoLogFileContext to libtest_util, and use it in bench by MarcoFalke)

    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.

  7. practicalswift commented at 12:53 pm on February 15, 2021: contributor

    Concept ACK

    Really like nanobench BTW: a really nice addition to Bitcoin Core!

  8. martinus commented at 1:00 pm on February 15, 2021: contributor

    Really like nanobench BTW: a really nice addition to Bitcoin Core!

    Thanks! Probably not widely known, but it is really helpful to run a benchmark in an endless loop like so:

    0NANOBENCH_ENDLESS=BlockToJsonVerbose ./src/bench/bench_bitcoin -filter=BlockToJsonVerbose
    

    And then fire up a profiler like perf top or hotspot to see where all the cycles are used up :)

  9. laanwj commented at 6:11 pm on March 1, 2021: member
    Code review ACK e3e0a2432c587ee06e469c37ffae133b7ac55c77
  10. laanwj merged this on Mar 1, 2021
  11. laanwj closed this on Mar 1, 2021

  12. sidhujag referenced this in commit 6f7b39ac12 on Mar 1, 2021
  13. DrahtBot locked this on Aug 16, 2022

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: 2024-12-19 06:12 UTC

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