From 1e774d0f2eaab7f6f7e1758c40f3ed21beeea8f0 Mon Sep 17 00:00:00 2001
From: Chris Sosnin <48099298+slumber@users.noreply.github.com>
Date: Thu, 9 Dec 2021 17:44:49 +0300
Subject: [PATCH] Increase the time limit for the perf-check cmd (#4498)

---
 polkadot/cli/src/host_perf_check.rs | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/polkadot/cli/src/host_perf_check.rs b/polkadot/cli/src/host_perf_check.rs
index 23190e94712..722deab7450 100644
--- a/polkadot/cli/src/host_perf_check.rs
+++ b/polkadot/cli/src/host_perf_check.rs
@@ -23,6 +23,8 @@ use polkadot_performance_test::{
 use std::time::Duration;
 
 pub fn host_perf_check() -> Result<(), PerfCheckError> {
+	let pvf_prepare_time_limit = time_limit_from_baseline(PVF_PREPARE_TIME_LIMIT);
+	let erasure_coding_time_limit = time_limit_from_baseline(ERASURE_CODING_TIME_LIMIT);
 	let wasm_code =
 		polkadot_performance_test::WASM_BINARY.ok_or(PerfCheckError::WasmBinaryMissing)?;
 
@@ -32,19 +34,25 @@ pub fn host_perf_check() -> Result<(), PerfCheckError> {
 
 	info!("Running the performance checks...");
 
-	perf_check("PVF-prepare", PVF_PREPARE_TIME_LIMIT, || measure_pvf_prepare(code.as_ref()))?;
+	perf_check("PVF-prepare", pvf_prepare_time_limit, || measure_pvf_prepare(code.as_ref()))?;
 
-	perf_check("Erasure-coding", ERASURE_CODING_TIME_LIMIT, || {
+	perf_check("Erasure-coding", erasure_coding_time_limit, || {
 		measure_erasure_coding(ERASURE_CODING_N_VALIDATORS, code.as_ref())
 	})?;
 
 	Ok(())
 }
 
+/// Returns a no-warning threshold for the given time limit.
 fn green_threshold(duration: Duration) -> Duration {
 	duration * 4 / 5
 }
 
+/// Returns an extended time limit to be used for the actual check.
+fn time_limit_from_baseline(duration: Duration) -> Duration {
+	duration * 3 / 2
+}
+
 fn perf_check(
 	test_name: &str,
 	time_limit: Duration,
-- 
GitLab