mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-04-29 14:59:39 -04:00
bench: measure CheckBlock
speed separately from serialization
> cmake -B build -DBUILD_BENCH=ON -DCMAKE_BUILD_TYPE=Release && cmake --build build -j$(nproc) && build/src/bench/bench_bitcoin -filter='CheckBlockBench|DuplicateInputs' -min-time=10000 > C++ compiler .......................... AppleClang 16.0.0.16000026 | ns/block | block/s | err% | total | benchmark |--------------------:|--------------------:|--------:|----------:|:---------- | 372,743.63 | 2,682.81 | 1.1% | 10.99 | `CheckBlockBench` | ns/op | op/s | err% | total | benchmark |--------------------:|--------------------:|--------:|----------:|:---------- | 3,304,694.54 | 302.60 | 0.5% | 11.05 | `DuplicateInputs` > C++ compiler .......................... GNU 13.3.0 | ns/block | block/s | err% | ins/block | cyc/block | IPC | bra/block | miss% | total | benchmark |--------------------:|--------------------:|--------:|----------------:|----------------:|-------:|---------------:|--------:|----------:|:---------- | 1,096,261.84 | 912.19 | 0.1% | 7,963,390.88 | 3,487,375.26 | 2.283 | 1,266,941.00 | 1.8% | 11.03 | `CheckBlockBench` | ns/op | op/s | err% | ins/op | cyc/op | IPC | bra/op | miss% | total | benchmark |--------------------:|--------------------:|--------:|----------------:|----------------:|-------:|---------------:|--------:|----------:|:---------- | 8,366,309.48 | 119.53 | 0.0% | 23,865,177.67 | 26,620,160.23 | 0.897 | 5,972,887.41 | 4.0% | 10.78 | `DuplicateInputs`
This commit is contained in:
parent
9a7f67030e
commit
ff9fb70c63
1 changed files with 10 additions and 18 deletions
|
@ -25,7 +25,7 @@
|
||||||
// a block off the wire, but before we can relay the block on to peers using
|
// a block off the wire, but before we can relay the block on to peers using
|
||||||
// compact block relay.
|
// compact block relay.
|
||||||
|
|
||||||
static void DeserializeBlockTest(benchmark::Bench& bench)
|
static void DeserializeBlockBench(benchmark::Bench& bench)
|
||||||
{
|
{
|
||||||
DataStream stream(benchmark::data::block413567);
|
DataStream stream(benchmark::data::block413567);
|
||||||
std::byte a{0};
|
std::byte a{0};
|
||||||
|
@ -39,26 +39,18 @@ static void DeserializeBlockTest(benchmark::Bench& bench)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
static void DeserializeAndCheckBlockTest(benchmark::Bench& bench)
|
static void CheckBlockBench(benchmark::Bench& bench)
|
||||||
{
|
{
|
||||||
DataStream stream(benchmark::data::block413567);
|
CBlock block;
|
||||||
std::byte a{0};
|
DataStream(benchmark::data::block413567) >> TX_WITH_WITNESS(block);
|
||||||
stream.write({&a, 1}); // Prevent compaction
|
const auto chainParams = CreateChainParams(ArgsManager{}, ChainType::MAIN);
|
||||||
|
|
||||||
ArgsManager bench_args;
|
|
||||||
const auto chainParams = CreateChainParams(bench_args, ChainType::MAIN);
|
|
||||||
|
|
||||||
bench.unit("block").run([&] {
|
bench.unit("block").run([&] {
|
||||||
CBlock block; // Note that CBlock caches its checked state, so we need to recreate it here
|
block.fChecked = block.m_checked_witness_commitment = block.m_checked_merkle_root = false; // Reset the cached state
|
||||||
stream >> TX_WITH_WITNESS(block);
|
|
||||||
bool rewound = stream.Rewind(benchmark::data::block413567.size());
|
|
||||||
assert(rewound);
|
|
||||||
|
|
||||||
BlockValidationState validationState;
|
BlockValidationState validationState;
|
||||||
bool checked = CheckBlock(block, validationState, chainParams->GetConsensus());
|
bool checked = CheckBlock(block, validationState, chainParams->GetConsensus(), /*fCheckPOW=*/true, /*fCheckMerkleRoot=*/true);
|
||||||
assert(checked);
|
assert(checked && validationState.IsValid());
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
BENCHMARK(DeserializeBlockTest, benchmark::PriorityLevel::HIGH);
|
BENCHMARK(DeserializeBlockBench, benchmark::PriorityLevel::HIGH);
|
||||||
BENCHMARK(DeserializeAndCheckBlockTest, benchmark::PriorityLevel::HIGH);
|
BENCHMARK(CheckBlockBench, benchmark::PriorityLevel::HIGH);
|
||||||
|
|
Loading…
Add table
Reference in a new issue