From 5c77cb2ba9a484dded95babc8686565fff579fb9 Mon Sep 17 00:00:00 2001 From: Adrien Cacciaguerra Date: Fri, 3 May 2024 15:13:24 -0400 Subject: [PATCH 1/4] chore: pass env to bench subprocesses This will ensure CodSpeed flamegraphs work --- scripts/bench.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/bench.ts b/scripts/bench.ts index 51531794001b..2dc63bd3cd03 100644 --- a/scripts/bench.ts +++ b/scripts/bench.ts @@ -25,6 +25,7 @@ async function run(benchmarks: string[]) { try { await execa.command(`pnpm tsx ${location}`, { stdio: 'inherit', + env: process.env, }) } catch (e) { console.error(e) From 41a425b85172120323dba4dc8a9d2318b0d6bf4b Mon Sep 17 00:00:00 2001 From: Adrien Cacciaguerra Date: Fri, 3 May 2024 16:15:05 -0400 Subject: [PATCH 2/4] chore: debug bench command --- .../__tests__/benchmarks/huge-schema/huge-schema.bench.ts | 6 ++++++ .../benchmarks/lots-of-relations/lots-of-relations.bench.ts | 6 ++++++ packages/get-platform/bench/get-platform.bench.ts | 6 ++++++ scripts/bench.ts | 1 + 4 files changed, 19 insertions(+) diff --git a/packages/client/src/__tests__/benchmarks/huge-schema/huge-schema.bench.ts b/packages/client/src/__tests__/benchmarks/huge-schema/huge-schema.bench.ts index 0c51a42b0f74..01c99f31ba5f 100644 --- a/packages/client/src/__tests__/benchmarks/huge-schema/huge-schema.bench.ts +++ b/packages/client/src/__tests__/benchmarks/huge-schema/huge-schema.bench.ts @@ -9,6 +9,12 @@ import path from 'path' import { compileFile } from '../../../utils/compileFile' import { generateTestClient } from '../../../utils/getTestClient' +console.log('process.execPath', process.execPath) +console.log('process.execArgv', process.execArgv) +console.log('process.argv', process.argv) +console.log('process.env', JSON.stringify(process.env, null, 2)) +throw new Error('stop') + let suite = withCodSpeed(new Benchmark.Suite('typescript')).add('client generation ~50 Models', { defer: true, fn: function (deferred) { diff --git a/packages/client/src/__tests__/benchmarks/lots-of-relations/lots-of-relations.bench.ts b/packages/client/src/__tests__/benchmarks/lots-of-relations/lots-of-relations.bench.ts index 3910f327b264..2e97bc60a521 100644 --- a/packages/client/src/__tests__/benchmarks/lots-of-relations/lots-of-relations.bench.ts +++ b/packages/client/src/__tests__/benchmarks/lots-of-relations/lots-of-relations.bench.ts @@ -5,6 +5,12 @@ import Benchmark from 'benchmark' import { generateTestClient } from '../../../utils/getTestClient' +console.log('process.execPath', process.execPath) +console.log('process.execArgv', process.execArgv) +console.log('process.argv', process.argv) +console.log('process.env', JSON.stringify(process.env, null, 2)) +throw new Error('stop') + const suite = withCodSpeed(new Benchmark.Suite('typescript')) // @ts-ignore // eslint-disable-next-line @typescript-eslint/no-floating-promises diff --git a/packages/get-platform/bench/get-platform.bench.ts b/packages/get-platform/bench/get-platform.bench.ts index 12d6af75da73..bab1d9484e66 100644 --- a/packages/get-platform/bench/get-platform.bench.ts +++ b/packages/get-platform/bench/get-platform.bench.ts @@ -3,6 +3,12 @@ import Benchmark from 'benchmark' import { getBinaryTargetForCurrentPlatformInternal, getos } from '../src/getPlatform' +console.log('process.execPath', process.execPath) +console.log('process.execArgv', process.execArgv) +console.log('process.argv', process.argv) +console.log('process.env', JSON.stringify(process.env, null, 2)) +throw new Error('stop') + void withCodSpeed(new Benchmark.Suite('get-platform')) .add('getBinaryTargetForCurrentPlatform', { defer: true, diff --git a/scripts/bench.ts b/scripts/bench.ts index 2dc63bd3cd03..9da3a78fd6a1 100644 --- a/scripts/bench.ts +++ b/scripts/bench.ts @@ -26,6 +26,7 @@ async function run(benchmarks: string[]) { await execa.command(`pnpm tsx ${location}`, { stdio: 'inherit', env: process.env, + execPath: process.execPath, }) } catch (e) { console.error(e) From 3cd7a0b4cfde423e0b9ebd9b64e03b91aaf7e54d Mon Sep 17 00:00:00 2001 From: Adrien Cacciaguerra Date: Fri, 3 May 2024 16:48:45 -0400 Subject: [PATCH 3/4] chore: debug bench command --- .github/workflows/benchmark.yml | 1 + scripts/bench.ts | 5 +++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml index c1f9b1fce44f..7ed5b3a2c6e2 100644 --- a/.github/workflows/benchmark.yml +++ b/.github/workflows/benchmark.yml @@ -68,3 +68,4 @@ jobs: token: ${{ secrets.CODSPEED_TOKEN }} env: CODSPEED_BENCHMARK: true + CODSPEED_DEBUG: true diff --git a/scripts/bench.ts b/scripts/bench.ts index 9da3a78fd6a1..836114a3aa7f 100644 --- a/scripts/bench.ts +++ b/scripts/bench.ts @@ -25,8 +25,9 @@ async function run(benchmarks: string[]) { try { await execa.command(`pnpm tsx ${location}`, { stdio: 'inherit', - env: process.env, - execPath: process.execPath, + // env: process.env, + // execPath: process.execPath, + execPath: 'node', }) } catch (e) { console.error(e) From 4c10b7c03af0c49a1e4b781150210d2f6f478a39 Mon Sep 17 00:00:00 2001 From: Adrien Cacciaguerra Date: Fri, 3 May 2024 16:55:27 -0400 Subject: [PATCH 4/4] chore: remove throw errors in benches --- .../src/__tests__/benchmarks/huge-schema/huge-schema.bench.ts | 1 - .../benchmarks/lots-of-relations/lots-of-relations.bench.ts | 1 - packages/get-platform/bench/get-platform.bench.ts | 1 - 3 files changed, 3 deletions(-) diff --git a/packages/client/src/__tests__/benchmarks/huge-schema/huge-schema.bench.ts b/packages/client/src/__tests__/benchmarks/huge-schema/huge-schema.bench.ts index 01c99f31ba5f..c830593afd68 100644 --- a/packages/client/src/__tests__/benchmarks/huge-schema/huge-schema.bench.ts +++ b/packages/client/src/__tests__/benchmarks/huge-schema/huge-schema.bench.ts @@ -13,7 +13,6 @@ console.log('process.execPath', process.execPath) console.log('process.execArgv', process.execArgv) console.log('process.argv', process.argv) console.log('process.env', JSON.stringify(process.env, null, 2)) -throw new Error('stop') let suite = withCodSpeed(new Benchmark.Suite('typescript')).add('client generation ~50 Models', { defer: true, diff --git a/packages/client/src/__tests__/benchmarks/lots-of-relations/lots-of-relations.bench.ts b/packages/client/src/__tests__/benchmarks/lots-of-relations/lots-of-relations.bench.ts index 2e97bc60a521..749d6134b41f 100644 --- a/packages/client/src/__tests__/benchmarks/lots-of-relations/lots-of-relations.bench.ts +++ b/packages/client/src/__tests__/benchmarks/lots-of-relations/lots-of-relations.bench.ts @@ -9,7 +9,6 @@ console.log('process.execPath', process.execPath) console.log('process.execArgv', process.execArgv) console.log('process.argv', process.argv) console.log('process.env', JSON.stringify(process.env, null, 2)) -throw new Error('stop') const suite = withCodSpeed(new Benchmark.Suite('typescript')) // @ts-ignore diff --git a/packages/get-platform/bench/get-platform.bench.ts b/packages/get-platform/bench/get-platform.bench.ts index bab1d9484e66..8d3115aefcb3 100644 --- a/packages/get-platform/bench/get-platform.bench.ts +++ b/packages/get-platform/bench/get-platform.bench.ts @@ -7,7 +7,6 @@ console.log('process.execPath', process.execPath) console.log('process.execArgv', process.execArgv) console.log('process.argv', process.argv) console.log('process.env', JSON.stringify(process.env, null, 2)) -throw new Error('stop') void withCodSpeed(new Benchmark.Suite('get-platform')) .add('getBinaryTargetForCurrentPlatform', {