-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(bench): make benchmark inputs deterministic using fixed seed #13586
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks! I have some suggestions on reducing some TestRunner
setup lines
fn criterion_benchmark(c: &mut Criterion) { | ||
let mut group = c.benchmark_group("priority"); | ||
group.sample_size(10); | ||
|
||
let config = ProptestConfig { | ||
rng_algorithm: prop::test_runner::RngAlgorithm::ChaCha, | ||
seed: 12345, | ||
..Default::default() | ||
}; | ||
|
||
let mut group = c.benchmark_group("Blob priority calculation"); | ||
let fee_jump_input = generate_test_data_fee_delta(); | ||
|
||
// Unstable sorting of unsorted collection | ||
fee_jump_bench(&mut group, "BenchmarkDynamicFeeJumpCalculation", fee_jump_input); | ||
|
||
let blob_priority_input = generate_test_data_priority(); | ||
|
||
// BinaryHeap that is resorted on each update | ||
priority_bench(&mut group, "BenchmarkPriorityCalculation", blob_priority_input); | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we should be making the existing benches deterministic, instead of adding a new bench
let mut runner = TestRunner::new(ProptestConfig { | ||
rng_algorithm: prop::test_runner::RngAlgorithm::ChaCha, | ||
seed: 12345, | ||
..Default::default() | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this should be using let mut runner = TestRunner::deterministic();
instead
@@ -30,7 +30,11 @@ pub fn trie_root_benchmark(c: &mut Criterion) { | |||
|
|||
fn generate_test_data(size: usize) -> Vec<ReceiptWithBloom<Receipt>> { | |||
prop::collection::vec(arb::<ReceiptWithBloom<Receipt>>(), size) | |||
.new_tree(&mut TestRunner::new(ProptestConfig::default())) | |||
.new_tree(&mut TestRunner::new(ProptestConfig { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same nit re: using the deterministic runner
crates/trie/sparse/benches/root.rs
Outdated
let mut runner = TestRunner::new(ProptestConfig { | ||
rng_algorithm: prop::test_runner::RngAlgorithm::ChaCha, | ||
seed: 12345, | ||
..Default::default() | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same nit re: using the deterministic runner
@Rjected I made some changes, could you pls review them? tnx |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks! almost there, looks like compile error is caused by an artifact of older changes?
let mut group = c.benchmark_group("priority"); | ||
group.sample_size(10); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
seems like this needs to be removed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
seems like this needs to be removed?
you're right, I changed, it seems to be that this one is what we need, or am I trippin'?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm, thanks!
CodSpeed Performance ReportMerging #13586 will improve performances by ×3.5Comparing Summary
Benchmarks breakdown
|
It was a pleasure to help you 🫡 Could you pls merge it? :) |
Towards #13535
Description of Changes
Made benchmark inputs deterministic by using a fixed seed for all random number generators. This resolves the issue of noise in test results on codspeed.
The changes include:
TestRunner
instances.crates/trie/sparse/benches/rlp_node.rs
crates/trie/sparse/benches/root.rs
crates/trie/trie/benches/trie_root.rs
crates/transaction-pool/benches/priority.rs
Testing
Additional Notes
This change does not affect the functionality of the code itself but ensures that benchmark results are more stable and reproducible.