feat: initialize Kurdistan SDK - independent fork of Polkadot SDK
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
# Run benches
|
||||
```
|
||||
cd erasure-coding # ensure you are in the right directory
|
||||
cargo bench
|
||||
```
|
||||
|
||||
## `scaling_with_validators`
|
||||
|
||||
This benchmark evaluates the performance of constructing the chunks and the erasure root from PoV and
|
||||
reconstructing the PoV from chunks (either from systematic chunks or regular chunks).
|
||||
You can see the results of running this bench on 5950x below (only including recovery from regular chunks).
|
||||
Interestingly, with `10_000` chunks (validators) its slower than with `50_000` for both construction
|
||||
and reconstruction.
|
||||
```
|
||||
construct/200 time: [93.924 ms 94.525 ms 95.214 ms]
|
||||
thrpt: [52.513 MiB/s 52.896 MiB/s 53.234 MiB/s]
|
||||
construct/500 time: [111.25 ms 111.52 ms 111.80 ms]
|
||||
thrpt: [44.721 MiB/s 44.837 MiB/s 44.946 MiB/s]
|
||||
construct/1000 time: [117.37 ms 118.28 ms 119.21 ms]
|
||||
thrpt: [41.941 MiB/s 42.273 MiB/s 42.601 MiB/s]
|
||||
construct/2000 time: [125.05 ms 125.72 ms 126.38 ms]
|
||||
thrpt: [39.564 MiB/s 39.772 MiB/s 39.983 MiB/s]
|
||||
construct/10000 time: [270.46 ms 275.11 ms 279.81 ms]
|
||||
thrpt: [17.869 MiB/s 18.174 MiB/s 18.487 MiB/s]
|
||||
construct/50000 time: [205.86 ms 209.66 ms 213.64 ms]
|
||||
thrpt: [23.404 MiB/s 23.848 MiB/s 24.288 MiB/s]
|
||||
|
||||
reconstruct/200 time: [180.73 ms 184.09 ms 187.73 ms]
|
||||
thrpt: [26.634 MiB/s 27.160 MiB/s 27.666 MiB/s]
|
||||
reconstruct/500 time: [195.59 ms 198.58 ms 201.76 ms]
|
||||
thrpt: [24.781 MiB/s 25.179 MiB/s 25.564 MiB/s]
|
||||
reconstruct/1000 time: [207.92 ms 211.57 ms 215.57 ms]
|
||||
thrpt: [23.195 MiB/s 23.633 MiB/s 24.048 MiB/s]
|
||||
reconstruct/2000 time: [218.59 ms 223.68 ms 229.18 ms]
|
||||
thrpt: [21.817 MiB/s 22.354 MiB/s 22.874 MiB/s]
|
||||
reconstruct/10000 time: [496.35 ms 505.17 ms 515.42 ms]
|
||||
thrpt: [9.7008 MiB/s 9.8977 MiB/s 10.074 MiB/s]
|
||||
reconstruct/50000 time: [276.56 ms 277.53 ms 278.58 ms]
|
||||
thrpt: [17.948 MiB/s 18.016 MiB/s 18.079 MiB/s]
|
||||
```
|
||||
|
||||
Results from running on an Apple M2 Pro, systematic recovery is generally 40 times faster than
|
||||
regular recovery, achieving 1 Gib/s.
|
||||
@@ -0,0 +1,118 @@
|
||||
// Copyright (C) Parity Technologies (UK) Ltd.
|
||||
// This file is part of Pezkuwi.
|
||||
|
||||
// Pezkuwi is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
|
||||
// Pezkuwi is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Pezkuwi. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
use criterion::{criterion_group, criterion_main, BenchmarkId, Criterion, Throughput};
|
||||
use pezkuwi_primitives::Hash;
|
||||
use std::time::Duration;
|
||||
|
||||
fn chunks(n_validators: usize, pov: &Vec<u8>) -> Vec<Vec<u8>> {
|
||||
pezkuwi_erasure_coding::obtain_chunks(n_validators, pov).unwrap()
|
||||
}
|
||||
|
||||
fn erasure_root(n_validators: usize, pov: &Vec<u8>) -> Hash {
|
||||
let chunks = chunks(n_validators, pov);
|
||||
pezkuwi_erasure_coding::branches(&chunks).root()
|
||||
}
|
||||
|
||||
fn construct_and_reconstruct_5mb_pov(c: &mut Criterion) {
|
||||
const N_VALIDATORS: [usize; 6] = [200, 500, 1000, 2000, 10_000, 50_000];
|
||||
|
||||
const KB: usize = 1024;
|
||||
const MB: usize = 1024 * KB;
|
||||
|
||||
let pov = vec![0xfe; 5 * MB];
|
||||
|
||||
let mut group = c.benchmark_group("construct");
|
||||
for n_validators in N_VALIDATORS {
|
||||
let expected_root = erasure_root(n_validators, &pov);
|
||||
|
||||
group.throughput(Throughput::Bytes(pov.len() as u64));
|
||||
group.bench_with_input(
|
||||
BenchmarkId::from_parameter(n_validators),
|
||||
&n_validators,
|
||||
|b, &n| {
|
||||
b.iter(|| {
|
||||
let root = erasure_root(n, &pov);
|
||||
assert_eq!(root, expected_root);
|
||||
});
|
||||
},
|
||||
);
|
||||
}
|
||||
group.finish();
|
||||
|
||||
let mut group = c.benchmark_group("reconstruct_regular");
|
||||
for n_validators in N_VALIDATORS {
|
||||
let all_chunks = chunks(n_validators, &pov);
|
||||
|
||||
let chunks: Vec<_> = all_chunks
|
||||
.iter()
|
||||
.enumerate()
|
||||
.take(pezkuwi_erasure_coding::recovery_threshold(n_validators).unwrap())
|
||||
.map(|(i, c)| (&c[..], i))
|
||||
.collect();
|
||||
|
||||
group.throughput(Throughput::Bytes(pov.len() as u64));
|
||||
group.bench_with_input(
|
||||
BenchmarkId::from_parameter(n_validators),
|
||||
&n_validators,
|
||||
|b, &n| {
|
||||
b.iter(|| {
|
||||
let _pov: Vec<u8> =
|
||||
pezkuwi_erasure_coding::reconstruct(n, chunks.clone()).unwrap();
|
||||
});
|
||||
},
|
||||
);
|
||||
}
|
||||
group.finish();
|
||||
|
||||
let mut group = c.benchmark_group("reconstruct_systematic");
|
||||
for n_validators in N_VALIDATORS {
|
||||
let all_chunks = chunks(n_validators, &pov);
|
||||
|
||||
let chunks = all_chunks
|
||||
.into_iter()
|
||||
.take(pezkuwi_erasure_coding::systematic_recovery_threshold(n_validators).unwrap())
|
||||
.collect::<Vec<_>>();
|
||||
|
||||
group.throughput(Throughput::Bytes(pov.len() as u64));
|
||||
group.bench_with_input(
|
||||
BenchmarkId::from_parameter(n_validators),
|
||||
&n_validators,
|
||||
|b, &n| {
|
||||
b.iter(|| {
|
||||
let _pov: Vec<u8> =
|
||||
pezkuwi_erasure_coding::reconstruct_from_systematic(n, chunks.clone())
|
||||
.unwrap();
|
||||
});
|
||||
},
|
||||
);
|
||||
}
|
||||
group.finish();
|
||||
}
|
||||
|
||||
fn criterion_config() -> Criterion {
|
||||
Criterion::default()
|
||||
.sample_size(15)
|
||||
.warm_up_time(Duration::from_millis(200))
|
||||
.measurement_time(Duration::from_secs(3))
|
||||
}
|
||||
|
||||
criterion_group!(
|
||||
name = re_construct;
|
||||
config = criterion_config();
|
||||
targets = construct_and_reconstruct_5mb_pov,
|
||||
);
|
||||
criterion_main!(re_construct);
|
||||
Reference in New Issue
Block a user