-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(core): rework ext message limits check
- Loading branch information
Showing
20 changed files
with
365 additions
and
169 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
use bytes::Bytes; | ||
use criterion::{criterion_group, criterion_main, Criterion}; | ||
use everscale_types::prelude::Boc; | ||
use tycho_block_util::message::ExtMsgRepr; | ||
|
||
use self::common::create_big_message; | ||
|
||
mod common; | ||
|
||
fn big_message_benchmark(c: &mut Criterion) { | ||
let boc = { | ||
let cell = create_big_message().unwrap(); | ||
Boc::encode(&cell) | ||
}; | ||
|
||
let bytes = Bytes::from(boc); | ||
c.bench_function("big-message", |b| { | ||
b.iter(|| { | ||
let _ = ExtMsgRepr::validate(bytes.clone()); | ||
}); | ||
}); | ||
} | ||
|
||
criterion_group!(benches, big_message_benchmark); | ||
criterion_main!(benches); |
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,36 @@ | ||
use everscale_types::cell::{Cell, CellBuilder, CellSliceRange}; | ||
use everscale_types::models::{MsgInfo, OwnedMessage}; | ||
use tycho_block_util::message::ExtMsgRepr; | ||
|
||
pub fn create_big_message() -> anyhow::Result<Cell> { | ||
let mut count = 0; | ||
let body = make_big_tree(8, &mut count, ExtMsgRepr::MAX_MSG_CELLS as u16 - 100); | ||
|
||
let body_range = CellSliceRange::full(body.as_ref()); | ||
|
||
let cell = CellBuilder::build_from(OwnedMessage { | ||
info: MsgInfo::ExtIn(Default::default()), | ||
init: None, | ||
body: (body, body_range), | ||
layout: None, | ||
})?; | ||
|
||
Ok(cell) | ||
} | ||
|
||
fn make_big_tree(depth: u8, count: &mut u16, target: u16) -> Cell { | ||
*count += 1; | ||
|
||
if depth == 0 { | ||
CellBuilder::build_from(*count).unwrap() | ||
} else { | ||
let mut b = CellBuilder::new(); | ||
for _ in 0..4 { | ||
if *count < target { | ||
b.store_reference(make_big_tree(depth - 1, count, target)) | ||
.unwrap(); | ||
} | ||
} | ||
b.build().unwrap() | ||
} | ||
} |
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,52 @@ | ||
use base64::prelude::Engine as _; | ||
use criterion::{criterion_group, criterion_main, Criterion}; | ||
use everscale_types::boc::Boc; | ||
use everscale_types::cell::{Cell, CellTreeStats}; | ||
use everscale_types::models::MsgInfo; | ||
use everscale_types::prelude::{CellFamily, Load}; | ||
use tycho_block_util::message::MsgStorageStat; | ||
|
||
use self::common::create_big_message; | ||
|
||
mod common; | ||
|
||
fn decode_benchmark(c: &mut Criterion) { | ||
let boc = { | ||
let cell = create_big_message().unwrap(); | ||
Boc::encode_base64(&cell) | ||
}; | ||
|
||
fn decode_base64_impl(data: &[u8]) -> Result<Vec<u8>, base64::DecodeError> { | ||
base64::engine::general_purpose::STANDARD.decode(data) | ||
} | ||
|
||
c.bench_function("decode-base64", |b| { | ||
b.iter(|| decode_base64_impl(boc.as_ref()).unwrap()); | ||
}); | ||
|
||
let x = decode_base64_impl(boc.as_ref()).unwrap(); | ||
|
||
c.bench_function("boc-decode-ext-base64", |b| { | ||
b.iter(|| Boc::decode_ext(x.as_ref(), Cell::empty_context())); | ||
}); | ||
|
||
let result = Boc::decode_ext(x.as_ref(), Cell::empty_context()).unwrap(); | ||
|
||
c.bench_function("owned-message-load", |b| { | ||
b.iter(|| MsgInfo::load_from(&mut result.as_slice().unwrap()).unwrap()); | ||
}); | ||
let cs = &mut result.as_slice().unwrap(); | ||
let _ = MsgInfo::load_from(cs).unwrap(); | ||
|
||
c.bench_function("traverse", |b| { | ||
b.iter(|| { | ||
MsgStorageStat::check_slice(cs, 2, CellTreeStats { | ||
bit_count: 1 << 21, | ||
cell_count: 1 << 13, | ||
}) | ||
}); | ||
}); | ||
} | ||
|
||
criterion_group!(benches, decode_benchmark); | ||
criterion_main!(benches); |
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
Oops, something went wrong.