diff --git a/nix/shell.nix b/nix/shell.nix index 9e9e5db37e6..aa96ab877dc 100644 --- a/nix/shell.nix +++ b/nix/shell.nix @@ -22,8 +22,12 @@ let ''; - # Underlying benchmarking library used by plutus-benchmark and tasty-papi - papi-pkgs = lib.optional pkgs.hostPlatform.isLinux pkgs.papi; + papi-pkgs = lib.optionals pkgs.hostPlatform.isLinux [ + # Needed to fix the frequency and governor of the CPU running the benchmarks + pkgs.cpufrequtils + # Underlying benchmarking library used by plutus-benchmark and tasty-papi + pkgs.papi + ]; all-pkgs = [ diff --git a/scripts/ci-plutus-benchmark.sh b/scripts/ci-plutus-benchmark.sh index f820ce51183..59f1784f2fb 100755 --- a/scripts/ci-plutus-benchmark.sh +++ b/scripts/ci-plutus-benchmark.sh @@ -68,6 +68,10 @@ cabal clean if [[ -z $(which taskset) ]]; then TASKSET="" else + echo "[ci-plutus-benchmark]: Setting CPU $CAPABILITY_NUM frequency governor to 'userspace' and frequency to 4.21GHz" + # This makes the benchmark reliable on a single core and addresses the issue of large variance in the results. + cpufreq-set --cpu $CAPABILITY_NUM --governor userspace + cpufreq-set --cpu $CAPABILITY_NUM --related --freq 4.21GHz TASKSET="taskset -c $CAPABILITY_NUM" fi