mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 10:59:55 +00:00
Update iai benchmarks to use iai-callgrind (#7534)
This commit is contained in:
7
.github/workflows/bench.yml
vendored
7
.github/workflows/bench.yml
vendored
@ -40,6 +40,13 @@ jobs:
|
||||
main -> target
|
||||
pr -> target
|
||||
cache-on-failure: true
|
||||
- name: Install iai-callgrind-runner
|
||||
run: |
|
||||
version=$(cargo metadata --format-version=1 |\
|
||||
jq '.packages[] | select(.name == "iai-callgrind").version' |\
|
||||
tr -d '"'
|
||||
)
|
||||
cargo install iai-callgrind-runner --version $version
|
||||
- name: Generate test vectors
|
||||
run: |
|
||||
cargo run --bin reth --manifest-path main/Cargo.toml -- test-vectors tables
|
||||
|
||||
61
Cargo.lock
generated
61
Cargo.lock
generated
@ -1021,12 +1021,15 @@ dependencies = [
|
||||
"itertools 0.12.1",
|
||||
"lazy_static",
|
||||
"lazycell",
|
||||
"log",
|
||||
"prettyplease",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"regex",
|
||||
"rustc-hash",
|
||||
"shlex",
|
||||
"syn 2.0.58",
|
||||
"which",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@ -3270,6 +3273,15 @@ dependencies = [
|
||||
"hmac 0.8.1",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "home"
|
||||
version = "0.5.9"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e3d1354bf6b7235cb4a0576c2619fd4ed18183f689b12b006a0ee7329eeff9a5"
|
||||
dependencies = [
|
||||
"windows-sys 0.52.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "hostname"
|
||||
version = "0.3.1"
|
||||
@ -3491,10 +3503,39 @@ dependencies = [
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "iai"
|
||||
version = "0.1.1"
|
||||
name = "iai-callgrind"
|
||||
version = "0.10.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "71a816c97c42258aa5834d07590b718b4c9a598944cd39a52dc25b351185d678"
|
||||
checksum = "e99bf26f496b13ac6273014f40afda46a233fbfb0289ce50fb4daaad2f2ffc80"
|
||||
dependencies = [
|
||||
"bincode",
|
||||
"bindgen",
|
||||
"cc",
|
||||
"iai-callgrind-macros",
|
||||
"iai-callgrind-runner",
|
||||
"regex",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "iai-callgrind-macros"
|
||||
version = "0.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e2a4bb39225592c0a28cfca6f70af52ebd8da23f533c2cdd0a3329c1fa252d56"
|
||||
dependencies = [
|
||||
"proc-macro-error",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.58",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "iai-callgrind-runner"
|
||||
version = "0.10.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c23a951b9eccaa1e38556d27473d1462a9c247a27961812edcaac156af861282"
|
||||
dependencies = [
|
||||
"serde",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "iana-time-zone"
|
||||
@ -6173,7 +6214,7 @@ dependencies = [
|
||||
"criterion",
|
||||
"derive_more",
|
||||
"eyre",
|
||||
"iai",
|
||||
"iai-callgrind",
|
||||
"metrics",
|
||||
"modular-bitfield",
|
||||
"once_cell",
|
||||
@ -9571,6 +9612,18 @@ dependencies = [
|
||||
"rustls-pki-types",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "which"
|
||||
version = "4.4.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "87ba24419a2078cd2b0f2ede2691b6c66d8e47836da3b6db8265ebad47afbfc7"
|
||||
dependencies = [
|
||||
"either",
|
||||
"home",
|
||||
"once_cell",
|
||||
"rustix",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "widestring"
|
||||
version = "1.1.0"
|
||||
|
||||
@ -60,7 +60,7 @@ test-fuzz.workspace = true
|
||||
|
||||
pprof = { workspace = true, features = ["flamegraph", "frame-pointer", "criterion"] }
|
||||
criterion.workspace = true
|
||||
iai = "0.1.1"
|
||||
iai-callgrind = "0.10.2"
|
||||
|
||||
arbitrary = { workspace = true, features = ["derive"] }
|
||||
proptest.workspace = true
|
||||
|
||||
@ -1,38 +1,42 @@
|
||||
#![allow(missing_docs, non_snake_case, unreachable_pub)]
|
||||
|
||||
use iai_callgrind::{
|
||||
library_benchmark, library_benchmark_group, LibraryBenchmarkConfig, RegressionConfig,
|
||||
};
|
||||
use paste::paste;
|
||||
use reth_db::table::{Compress, Decode, Decompress, Encode, Table};
|
||||
|
||||
mod utils;
|
||||
use utils::*;
|
||||
|
||||
macro_rules! impl_iai_inner {
|
||||
macro_rules! impl_iai_callgrind_inner {
|
||||
(
|
||||
$(($name:ident, $mod:ident, $compress:ident, $decompress:ident, $encode:ident, $decode:ident, $seqread:ident, $randread:ident, $seqwrite:ident, $randwrite:ident))+
|
||||
$(($name:ident, $group_name:ident, $mod:ident, $compress:ident, $decompress:ident, $encode:ident, $decode:ident, $seqread:ident, $randread:ident, $seqwrite:ident, $randwrite:ident))+
|
||||
) => {
|
||||
use std::hint::black_box;
|
||||
$(
|
||||
mod $mod {
|
||||
use super::*;
|
||||
use std::hint::black_box;
|
||||
|
||||
#[library_benchmark]
|
||||
pub fn $compress() {
|
||||
for (_, _, v, _) in black_box(load_vectors::<reth_db::tables::$name>()) {
|
||||
black_box(v.compress());
|
||||
}
|
||||
}
|
||||
|
||||
#[library_benchmark]
|
||||
pub fn $decompress() {
|
||||
for (_, _, _, comp) in black_box(load_vectors::<reth_db::tables::$name>()) {
|
||||
let _ = black_box(<reth_db::tables::$name as Table>::Value::decompress(comp));
|
||||
}
|
||||
}
|
||||
|
||||
#[library_benchmark]
|
||||
pub fn $encode() {
|
||||
for (k, _, _, _) in black_box(load_vectors::<reth_db::tables::$name>()) {
|
||||
black_box(k.encode());
|
||||
}
|
||||
}
|
||||
|
||||
#[library_benchmark]
|
||||
pub fn $decode() {
|
||||
for (_, enc, _, _) in black_box(load_vectors::<reth_db::tables::$name>()) {
|
||||
let _ = black_box(<reth_db::tables::$name as Table>::Key::decode(enc));
|
||||
@ -50,34 +54,41 @@ macro_rules! impl_iai_inner {
|
||||
|
||||
#[allow(dead_code)]
|
||||
pub fn $randwrite() {}
|
||||
}
|
||||
use $mod::*;
|
||||
|
||||
|
||||
library_benchmark_group!(
|
||||
name = $group_name;
|
||||
config = LibraryBenchmarkConfig::default()
|
||||
.regression(
|
||||
RegressionConfig::default().fail_fast(false)
|
||||
);
|
||||
benchmarks =
|
||||
$compress,
|
||||
$decompress,
|
||||
$encode,
|
||||
$decode,
|
||||
);
|
||||
)+
|
||||
|
||||
iai::main!(
|
||||
$(
|
||||
$compress,
|
||||
$decompress,
|
||||
$encode,
|
||||
$decode,
|
||||
)+
|
||||
);
|
||||
iai_callgrind::main!(
|
||||
config = LibraryBenchmarkConfig::default();
|
||||
library_benchmark_groups = $($group_name),+);
|
||||
};
|
||||
}
|
||||
|
||||
macro_rules! impl_iai {
|
||||
macro_rules! impl_iai_callgrind {
|
||||
($($name:ident),+) => {
|
||||
paste! {
|
||||
impl_iai_inner!(
|
||||
impl_iai_callgrind_inner!(
|
||||
$(
|
||||
( $name, [<$name _mod>], [<$name _ValueCompress>], [<$name _ValueDecompress>], [<$name _ValueEncode>], [<$name _ValueDecode>], [<$name _SeqRead>], [<$name _RandomRead>], [<$name _SeqWrite>], [<$name _RandomWrite>])
|
||||
( $name, [<$name _group>],[<$name _mod>], [<$name _ValueCompress>], [<$name _ValueDecompress>], [<$name _ValueEncode>], [<$name _ValueDecode>], [<$name _SeqRead>], [<$name _RandomRead>], [<$name _SeqWrite>], [<$name _RandomWrite>])
|
||||
)+
|
||||
);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
impl_iai!(
|
||||
impl_iai_callgrind!(
|
||||
CanonicalHeaders,
|
||||
HeaderTerminalDifficulties,
|
||||
HeaderNumbers,
|
||||
|
||||
Reference in New Issue
Block a user