Bitcoin nodes update their TxConfirmStats attributes (eg. confAvg, failAvg
etc..) whenever they see a new block. However, during IBD, we know our best block height, so we can skip the parameter updates up to a certain height, when we know they are not going to affect fee estimates.
We can see the max value of decay for parameters is .99931. If we do (max_decay)^6048 which is approximate 0.01, it means, that transactions in blocks older than this height, do not affect the current fee estimates significantly. (i.e ~ Best_Block_Height - 6048).
By skipping these updates we can reduce the computation complexity of fee calculation during IBD significantly: (block_tree_size - 6048)/block_tree_size*100 which is ~ 99%.
I got to know about the functions to optimize by analyzing the profiling data of bitcoind
. It can be generated via ./configure CC=clang CXX=clang++ CXXFLAGS="-fprofile-instr-generate=bitcoind-%p.profraw