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

Run subsystem-benchmark without network latency #4068

Merged
merged 4 commits into from
Apr 11, 2024
Merged
Show file tree
Hide file tree
Changes from 2 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
4 changes: 2 additions & 2 deletions .gitlab/pipeline/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -524,8 +524,8 @@ subsystem-regression-tests:
- .common-refs
- .run-immediately
script:
- cargo bench --profile=testnet -p polkadot-availability-recovery --bench availability-recovery-regression-bench --features subsystem-benchmarks
- cargo bench --profile=testnet -p polkadot-availability-distribution --bench availability-distribution-regression-bench --features subsystem-benchmarks
- cargo bench -p polkadot-availability-recovery --bench availability-recovery-regression-bench --features subsystem-benchmarks
- cargo bench -p polkadot-availability-distribution --bench availability-distribution-regression-bench --features subsystem-benchmarks
tags:
- benchmark
allow_failure: true
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ use polkadot_subsystem_bench::{
};
use std::io::Write;

const BENCH_COUNT: usize = 50;
const BENCH_COUNT: usize = 5;

fn main() -> Result<(), String> {
let mut messages = vec![];
Expand All @@ -40,6 +40,8 @@ fn main() -> Result<(), String> {
config.n_cores = 10;
config.n_validators = 500;
config.num_blocks = 3;
config.connectivity = 100;
config.latency = None;
config.generate_pov_sizes();
let state = TestState::new(&config);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,16 @@ use polkadot_subsystem_bench::{
};
use std::io::Write;

const BENCH_COUNT: usize = 50;
const BENCH_COUNT: usize = 5;

fn main() -> Result<(), String> {
let mut messages = vec![];

let options = DataAvailabilityReadOptions { fetch_from_backers: true };
let mut config = TestConfiguration::default();
config.num_blocks = 3;
config.connectivity = 100;
config.latency = None;
config.generate_pov_sizes();

let state = TestState::new(&config);
Expand Down
22 changes: 10 additions & 12 deletions polkadot/node/subsystem-bench/src/lib/network.rs
Original file line number Diff line number Diff line change
Expand Up @@ -474,19 +474,17 @@ impl EmulatedPeer {
pub async fn send_message(&mut self, message: NetworkMessage) {
self.tx_limiter.reap(message.size()).await;

if self.latency_ms == 0 {
self.to_node.unbounded_send(message).expect("Sending to the node never fails");
} else {
let to_node = self.to_node.clone();
let latency_ms = std::time::Duration::from_millis(self.latency_ms as u64);

// Emulate RTT latency
self.spawn_handle
.spawn("peer-latency-emulator", "test-environment", async move {
let to_node = self.to_node.clone();
let latency_ms = std::time::Duration::from_millis(self.latency_ms as u64);

self.spawn_handle
.spawn("peer-latency-emulator", "test-environment", async move {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure I understand how this should help, we would actually get scheduling noise even if latency is zero, so this change would work against making the test more deterministic by setting latency to None.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have the same question. How much of an improvement are we seeing and do we have any clue why that is ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are right, I used to receive weird results with sending without spawning, but now checked again and everything is ok. I suppose I just had some "noise" on my laptop because of rust-analyzer.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would use a VM with ref hw specs to run the tests and establish gold values for the asserts.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, I reverted that

// Emulate RTT latency
if !latency_ms.is_zero() {
tokio::time::sleep(latency_ms).await;
to_node.unbounded_send(message).expect("Sending to the node never fails");
});
}
}
to_node.unbounded_send(message).expect("Sending to the node never fails");
});
}

/// Returns the rx bandwidth limiter.
Expand Down
Loading