-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: rewrite queue-msg normalization pass (#3026)
closes #3003 results: ``` normalize time: [15.757 µs 15.946 µs 16.192 µs] // old normalize2 time: [5.5628 µs 5.5822 µs 5.6047 µs] // new ``` also removed some unused `Op` variants.
- Loading branch information
Showing
8 changed files
with
237 additions
and
886 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
use criterion::{black_box, criterion_group, criterion_main, Criterion}; | ||
use queue_msg::{call, conc, data, noop, normalize::normalize, promise, seq, Op}; | ||
use unionlabs::ibc::core::client::height::Height; | ||
use voyager_message::{ | ||
call::FetchBlock, callback::AggregateFetchBlockRange, core::ChainId, data::LatestHeight, | ||
VoyagerMessage, | ||
}; | ||
|
||
fn bench_normalize(c: &mut Criterion) { | ||
c.bench_function("normalize", |b| { | ||
b.iter_with_setup( | ||
|| vec![mk_msg(), mk_msg(), mk_msg()], | ||
|msgs| black_box(normalize(msgs)), | ||
) | ||
}); | ||
} | ||
|
||
fn mk_msg() -> Op<VoyagerMessage> { | ||
seq([ | ||
promise( | ||
[ | ||
data(LatestHeight { | ||
chain_id: ChainId::new("chain"), | ||
height: Height { | ||
revision_number: 1, | ||
revision_height: 1, | ||
}, | ||
}), | ||
call(FetchBlock { | ||
chain_id: ChainId::new("chain"), | ||
height: Height { | ||
revision_number: 1, | ||
revision_height: 1, | ||
}, | ||
}), | ||
conc([ | ||
noop(), | ||
data(LatestHeight { | ||
chain_id: ChainId::new("chain"), | ||
height: Height { | ||
revision_number: 1, | ||
revision_height: 1, | ||
}, | ||
}), | ||
call(FetchBlock { | ||
chain_id: ChainId::new("chain"), | ||
height: Height { | ||
revision_number: 1, | ||
revision_height: 1, | ||
}, | ||
}), | ||
]), | ||
], | ||
[], | ||
AggregateFetchBlockRange { | ||
from_height: Height { | ||
revision_number: 1, | ||
revision_height: 1, | ||
}, | ||
}, | ||
), | ||
seq([ | ||
data(LatestHeight { | ||
chain_id: ChainId::new("chain"), | ||
height: Height { | ||
revision_number: 1, | ||
revision_height: 1, | ||
}, | ||
}), | ||
call(FetchBlock { | ||
chain_id: ChainId::new("chain"), | ||
height: Height { | ||
revision_number: 1, | ||
revision_height: 1, | ||
}, | ||
}), | ||
conc([ | ||
noop(), | ||
data(LatestHeight { | ||
chain_id: ChainId::new("chain"), | ||
height: Height { | ||
revision_number: 1, | ||
revision_height: 1, | ||
}, | ||
}), | ||
call(FetchBlock { | ||
chain_id: ChainId::new("chain"), | ||
height: Height { | ||
revision_number: 1, | ||
revision_height: 1, | ||
}, | ||
}), | ||
]), | ||
]), | ||
]) | ||
} | ||
|
||
criterion_group!(benches, bench_normalize); | ||
|
||
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
Oops, something went wrong.