This repository has been archived by the owner on Feb 21, 2024. It is now read-only.
forked from paritytech/substrate
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request paritytech#224 from subspace/archiving-optimizations
Archiving optimizations
- Loading branch information
Showing
11 changed files
with
338 additions
and
75 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
#![feature(int_log)] | ||
|
||
use criterion::{criterion_group, criterion_main, Criterion}; | ||
use subspace_archiving::archiver::Archiver; | ||
use subspace_core_primitives::{PIECE_SIZE, SHA256_HASH_SIZE}; | ||
|
||
const MERKLE_NUM_LEAVES: u32 = 256; | ||
const WITNESS_SIZE: u32 = SHA256_HASH_SIZE as u32 * MERKLE_NUM_LEAVES.log2(); | ||
pub const RECORD_SIZE: u32 = PIECE_SIZE as u32 - WITNESS_SIZE; | ||
pub const RECORDED_HISTORY_SEGMENT_SIZE: u32 = RECORD_SIZE * MERKLE_NUM_LEAVES / 2; | ||
|
||
pub fn criterion_benchmark(c: &mut Criterion) { | ||
let mut input = Vec::<u8>::with_capacity(RECORDED_HISTORY_SEGMENT_SIZE.try_into().unwrap()); | ||
input.resize(input.capacity(), 1); | ||
|
||
c.bench_function("archiving-2-blocks", |b| { | ||
b.iter(|| { | ||
let mut archiver = Archiver::new( | ||
RECORD_SIZE.try_into().unwrap(), | ||
RECORDED_HISTORY_SEGMENT_SIZE.try_into().unwrap(), | ||
) | ||
.unwrap(); | ||
for _ in 0..2 { | ||
archiver.add_block(input.clone(), Default::default()); | ||
} | ||
}) | ||
}); | ||
} | ||
|
||
criterion_group!(benches, criterion_benchmark); | ||
criterion_main!(benches); |
Oops, something went wrong.