Page MenuHomePhabricator

ConnectBlock: don't serialize block hash twice
ClosedPublic

Authored by Fabien on Nov 30 2022, 16:31.

Details

Reviewers
PiRK
sdulfari
Group Reviewers
Restricted Project
Commits
rABCc3ed96a41c49: ConnectBlock: don't serialize block hash twice
Summary
In the validation:block_connected tracepoint, we call block->GetHash(), which
ends up calling CBlockHeader::GetHash(), executing around 8000 serialization
instructions. We don't need to do this extra work, because block->GetHash() is
already called further up in the function. Let's save that value as a local
variable and re-use it in our tracepoint so there is no unnecessary tracepoint
overhead.

Shave off an extra 100 or so instructions from the validation:block_connected
tracepoint by reusing a nearby GetTimeMicros(). This brings the tracepoint down
to 54 instructions. Still high, but much better than the previous ~154 and
8000 instructions which it was originally.

Backport of core#23819.

Depends on D12674.

Test Plan
sudo bpftrace ../contrib/tracing/connectblock_benchmark.bt 0 0 25

Diff Detail

Repository
rABC Bitcoin ABC
Lint
Lint Not Applicable
Unit
Tests Not Applicable