Skip to content
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(net): make benchmark inputs deterministic #13563

Merged
merged 2 commits into from
Dec 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions crates/net/network/benches/broadcast.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
#![allow(missing_docs)]
use alloy_primitives::U256;
use alloy_primitives::{
private::proptest::test_runner::{RngAlgorithm, TestRng},
U256,
};
use criterion::*;
use futures::StreamExt;
use pprof::criterion::{Output, PProfProfiler};
use rand::thread_rng;
use reth_network::{test_utils::Testnet, NetworkEventListenerProvider};
use reth_network_api::Peers;
use reth_provider::test_utils::{ExtendedAccount, MockEthProvider};
Expand Down Expand Up @@ -49,7 +51,9 @@ pub fn broadcast_ingress_bench(c: &mut Criterion) {
}

// prepare some transactions
let mut gen = TransactionGenerator::new(thread_rng());
let mut gen = TransactionGenerator::new(TestRng::deterministic_rng(
RngAlgorithm::ChaCha,
));
let num_broadcasts = 10;
for _ in 0..num_broadcasts {
for _ in 0..2 {
Expand Down
12 changes: 9 additions & 3 deletions crates/net/network/benches/tx_manager_hash_fetching.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
#![allow(missing_docs)]
use alloy_primitives::U256;

use alloy_primitives::{
private::proptest::test_runner::{RngAlgorithm, TestRng},
U256,
};
use criterion::*;
use pprof::criterion::{Output, PProfProfiler};
use rand::thread_rng;
use reth_network::{
test_utils::Testnet,
transactions::{
Expand Down Expand Up @@ -61,7 +64,10 @@ pub fn tx_fetch_bench(c: &mut Criterion) {
let peer_pool = peer.pool().unwrap();

for _ in 0..num_tx_per_peer {
let mut gen = TransactionGenerator::new(thread_rng());
let mut gen = TransactionGenerator::new(
TestRng::deterministic_rng(RngAlgorithm::ChaCha),
);

let tx = gen.gen_eip1559_pooled();
let sender = tx.sender();
provider.add_account(
Expand Down
Loading