From 25f038aa8e381911832450b2e2452d5cc64dfe37 Mon Sep 17 00:00:00 2001
From: Andrei Eres <eresav@me.com>
Date: Thu, 11 Apr 2024 18:54:59 +0200
Subject: [PATCH] Run subsystem-benchmark without network latency (#4068)

Implements the idea from
https://github.com/paritytech/polkadot-sdk/pull/3899
- Removed latencies
- Number of runs reduced from 50 to 5, according to local runs it's
quite enough
- Network message is always sent in a spawned task, even if latency is
zero. Without it, CPU time sometimes spikes.
- Removed the `testnet` profile because we probably don't need that
debug additions.

After the local tests I can't say that it brings a significant
improvement in the stability of the results. However, I belive it is
worth trying and looking at the results over time.
---
 .gitlab/pipeline/test.yml                                     | 4 ++--
 .../benches/availability-distribution-regression-bench.rs     | 4 +++-
 .../benches/availability-recovery-regression-bench.rs         | 4 +++-
 3 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/.gitlab/pipeline/test.yml b/.gitlab/pipeline/test.yml
index 76f3533c296..1d6efd7b9fd 100644
--- a/.gitlab/pipeline/test.yml
+++ b/.gitlab/pipeline/test.yml
@@ -524,7 +524,7 @@ subsystem-benchmark-availability-recovery:
     - .common-refs
     - .run-immediately
   script:
-    - cargo bench --profile=testnet -p polkadot-availability-recovery --bench availability-recovery-regression-bench --features subsystem-benchmarks
+    - cargo bench -p polkadot-availability-recovery --bench availability-recovery-regression-bench --features subsystem-benchmarks
   tags:
     - benchmark
   allow_failure: true
@@ -542,7 +542,7 @@ subsystem-benchmark-availability-distribution:
     - .common-refs
     - .run-immediately
   script:
-    - cargo bench --profile=testnet -p polkadot-availability-distribution --bench availability-distribution-regression-bench --features subsystem-benchmarks
+    - cargo bench -p polkadot-availability-distribution --bench availability-distribution-regression-bench --features subsystem-benchmarks
   tags:
     - benchmark
   allow_failure: true
diff --git a/polkadot/node/network/availability-distribution/benches/availability-distribution-regression-bench.rs b/polkadot/node/network/availability-distribution/benches/availability-distribution-regression-bench.rs
index c33674a8f2f..0d4f4f49e31 100644
--- a/polkadot/node/network/availability-distribution/benches/availability-distribution-regression-bench.rs
+++ b/polkadot/node/network/availability-distribution/benches/availability-distribution-regression-bench.rs
@@ -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![];
@@ -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);
 
diff --git a/polkadot/node/network/availability-recovery/benches/availability-recovery-regression-bench.rs b/polkadot/node/network/availability-recovery/benches/availability-recovery-regression-bench.rs
index 46a38516898..9be147bda93 100644
--- a/polkadot/node/network/availability-recovery/benches/availability-recovery-regression-bench.rs
+++ b/polkadot/node/network/availability-recovery/benches/availability-recovery-regression-bench.rs
@@ -32,7 +32,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![];
@@ -40,6 +40,8 @@ fn main() -> Result<(), String> {
 	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);
-- 
GitLab