From d3a13f8473b46f11671166f8b6691668cc2449ea Mon Sep 17 00:00:00 2001 From: Yaacov Rydzinski Date: Tue, 7 Jun 2022 20:50:27 +0300 Subject: [PATCH 1/3] benchmark: increase process priority to try to avoid involuntary context switches --- .github/workflows/cmd-run-benchmark.yml | 2 +- resources/benchmark.ts | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/cmd-run-benchmark.yml b/.github/workflows/cmd-run-benchmark.yml index f17e7ed2f0..df432ecdb7 100644 --- a/.github/workflows/cmd-run-benchmark.yml +++ b/.github/workflows/cmd-run-benchmark.yml @@ -33,7 +33,7 @@ jobs: - name: Run Benchmark run: | - npm run benchmark -- --revs HEAD BASE + sudo npm run benchmark -- --revs HEAD BASE - name: Create replyMessage uses: actions/github-script@v6 diff --git a/resources/benchmark.ts b/resources/benchmark.ts index 9524dea748..6a9ad30e63 100644 --- a/resources/benchmark.ts +++ b/resources/benchmark.ts @@ -381,9 +381,12 @@ function sampleModule(modulePath: string): BenchmarkSample { const sampleCode = ` import fs from 'node:fs'; + import os from 'node:os'; import { benchmark } from '${moduleURL}'; + os.setPriority(os.constants.priority.PRIORITY_HIGHEST); + // warm up, it looks like 7 is a magic number to reliably trigger JIT benchmark.measure(); benchmark.measure(); From fb36913274e0e7996d9091e5211765771d11382a Mon Sep 17 00:00:00 2001 From: Yaacov Rydzinski Date: Wed, 8 Jun 2022 16:46:19 +0300 Subject: [PATCH 2/3] try manually passing along the uid --- resources/benchmark.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/resources/benchmark.ts b/resources/benchmark.ts index 6a9ad30e63..50e0abfb87 100644 --- a/resources/benchmark.ts +++ b/resources/benchmark.ts @@ -435,6 +435,7 @@ function sampleModule(modulePath: string): BenchmarkSample { { stdio: ['inherit', 'inherit', 'inherit', 'pipe'], env: { NODE_ENV: 'production' }, + uid: process.getuid(), }, ); From e7fc7dd897ca519b7992dc873a2ff22a0ebf71d7 Mon Sep 17 00:00:00 2001 From: Yaacov Rydzinski Date: Wed, 8 Jun 2022 17:00:45 +0300 Subject: [PATCH 3/3] try inner sudo @IvanGoncharov sudo on the benchmark was not working did not seem to pass through --- .github/workflows/cmd-run-benchmark.yml | 2 +- resources/benchmark.ts | 8 +++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/.github/workflows/cmd-run-benchmark.yml b/.github/workflows/cmd-run-benchmark.yml index df432ecdb7..f17e7ed2f0 100644 --- a/.github/workflows/cmd-run-benchmark.yml +++ b/.github/workflows/cmd-run-benchmark.yml @@ -33,7 +33,7 @@ jobs: - name: Run Benchmark run: | - sudo npm run benchmark -- --revs HEAD BASE + npm run benchmark -- --revs HEAD BASE - name: Create replyMessage uses: actions/github-script@v6 diff --git a/resources/benchmark.ts b/resources/benchmark.ts index 50e0abfb87..6f82f19666 100644 --- a/resources/benchmark.ts +++ b/resources/benchmark.ts @@ -417,8 +417,10 @@ function sampleModule(modulePath: string): BenchmarkSample { `; const result = cp.spawnSync( - process.execPath, + 'sudo', [ + '--close-from=4', + `"${process.execPath}"`, // V8 flags '--predictable', '--no-concurrent-sweeping', @@ -430,12 +432,12 @@ function sampleModule(modulePath: string): BenchmarkSample { // Node.js flags '--input-type=module', '--eval', - sampleCode, + `"${sampleCode}"`, ], { + shell: true, stdio: ['inherit', 'inherit', 'inherit', 'pipe'], env: { NODE_ENV: 'production' }, - uid: process.getuid(), }, );