Bitcoin Forum
May 06, 2024, 01:27:54 AM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: BCLog::Bench - Timing nothing of value  (Read 52 times)
dougEfish (OP)
Newbie
*
Offline Offline

Activity: 7
Merit: 27


View Profile
September 22, 2021, 02:44:28 PM
Merited by ABCbits (2)
 #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.
"Governments are good at cutting off the heads of a centrally controlled networks like Napster, but pure P2P networks like Gnutella and Tor seem to be holding their own." -- Satoshi
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction.
achow101
Moderator
Legendary
*
expert
Offline Offline

Activity: 3388
Merit: 6581


Just writing some code


View Profile WWW
September 22, 2021, 04:24:50 PM
Merited by ABCbits (2)
 #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.

dougEfish (OP)
Newbie
*
Offline Offline

Activity: 7
Merit: 27


View Profile
September 23, 2021, 08:51:36 AM
 #3

Thanks

PR https://github.com/bitcoin/bitcoin/pull/23072

Issue https://github.com/bitcoin/bitcoin/issues/23071
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!