Author

Topic: BCLog::Bench - Timing nothing of value (Read 67 times)

staff
Activity: 3458
Merit: 6793
Just writing some code
September 22, 2021, 11:24:50 AM
#2
Looking at when that was added, there was stuff in between those log lines which are reasonable to benchmark. Those were the callbacks to the wallet to add the transaction to the wallet, hence the log line "callbacks". But that has since moved elsewhere and become asynchronous, so this log line isn't doing anything useful and could be removed.
newbie
Activity: 7
Merit: 27
September 22, 2021, 09:44:28 AM
#1
I recently setup up a new node and was perplexed why processing the chain took longer than expected.
I'm downloading  from another node on my local gigabit network, so bandwidth wasn't my bottleneck. 
I saw a -debug flag with a bench property, so I enabled this setting.  Long story short, the disk I used was really slow.

Anyways, I came across some code that doesn't seem to time anything of value:


Code:
    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);


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

Correct if I'm wrong, but it seems "Callbacks" is timing the execution of the "Index writing" LogPrintf along with some basic computations (nTime6 - nTime5)
Inspection of my debug.log indicates a consistent time of around  ~20-30 microseconds.

Is this timing anything of value?

Callbacks bench was added (I think) in this commit: https://github.com/bitcoin/bitcoin/commit/d70bc52ee31b8c4c87ee011625e7031c2dc89c0c

If this is dead (legacy) code, I'll open merge request and remove it. Could someone confirm ?

Thanks.
Jump to: