BCLog::Bench Callbacks timing nothing of value #23071

issue dougEfresh opened this issue on September 23, 2021
  1. dougEfresh commented at 8:06 AM on September 23, 2021: contributor

    Expected behavior

    LogPrint BCLog::BENCH should print useful timing metrics

    Actual behavior

    Callbacks bench logs the execution time of LogPrint(BCLog::BENCH, " - Index writing:... function call

        int64_t nTime5 = GetTimeMicros(); nTimeIndex += nTime5 - nTime4;
        LogPrint(BCLog::BENCH, "    - Index writing: %.2fms [%.2fs (%.2fms/blk)]\n", MILLI * (nTime5 - nTime4), nTimeIndex * MICRO, nTimeIndex * MILLI / nBlocksTotal);
    
        int64_t nTime6 = GetTimeMicros(); nTimeCallbacks += nTime6 - nTime5;
        LogPrint(BCLog::BENCH, "    - Callbacks: %.2fms [%.2fs (%.2fms/blk)]\n", MILLI * (nTime6 - nTime5), nTimeCallbacks * MICRO, nTimeCallbacks * MILLI / nBlocksTotal);
    

    https://github.com/bitcoin/bitcoin/blob/master/src/validation.cpp#L1873

    Callbacks bench was added in this commit: https://github.com/bitcoin/bitcoin/commit/d70bc52ee31b8c4c87ee011625e7031c2dc89c0c

    Since then functions between Index writing: and Callbacks: were moved. Now Callbacks bench isn't recording anything of value. Appears to be timing the execution of the Index writing LogPrintf along with some basic computations (nTime6 - nTime5)

    To reproduce

    Start a node with initial block download

    bitcoind -debug=bench | grep Callbacks:
    

    You'll see the times recorded are within a small bounded range. On my system it was between 30-50 microseconds

    System information

    Self-complied tag v22.0 on Arch Linux x86s AMD Ryzen 5 with SSD and 8 gigs ram

    I will open a PR to remove this code

  2. dougEfresh added the label Bug on Sep 23, 2021
  3. MarcoFalke referenced this in commit 95b16e70a8 on Sep 23, 2021
  4. MarcoFalke closed this on Sep 23, 2021

  5. DrahtBot locked this on Oct 30, 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: 2026-04-29 03:14 UTC

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