Add CI toggle to skip benchmark thread sweep
Co-authored-by: Julius Marminge <[email protected]>
This commit is contained in:
1 parent
b3460f699a
commit
d69f055597
4 files changed
+65
-20
No files matched your search
@@ -83,6 +83,7 @@ jobs:
|
||||
# Terminal PTY scripting is flaky in CI VMs; renderer perf checks remain enforced.
|
||||
T3CODE_DESKTOP_PERF_RUN_TERMINAL: "0"
|
||||
T3CODE_DESKTOP_PERF_RUN_OPTIONAL_RENDERER: "0"
|
||||
T3CODE_DESKTOP_PERF_RUN_BENCHMARK_SWEEP: "0"
|
||||
T3CODE_DESKTOP_PERF_BENCHMARK_FOLLOW_UP_PASSES: "0"
|
||||
T3CODE_ELECTRON_STARTUP_TIMEOUT_MS: "180000"
|
||||
run: xvfb-run -a bun run test:desktop-perf
|
||||
@@ -95,6 +96,7 @@ jobs:
|
||||
T3CODE_PERF_MAX_LONG_DISPATCH_COUNT: "5"
|
||||
T3CODE_DESKTOP_PERF_RUN_TERMINAL: "0"
|
||||
T3CODE_DESKTOP_PERF_RUN_OPTIONAL_RENDERER: "0"
|
||||
T3CODE_DESKTOP_PERF_RUN_BENCHMARK_SWEEP: "0"
|
||||
T3CODE_DESKTOP_PERF_BENCHMARK_FOLLOW_UP_PASSES: "0"
|
||||
T3CODE_ELECTRON_STARTUP_TIMEOUT_MS: "180000"
|
||||
run: xvfb-run -a bun run test:desktop-perf
|
||||
@@ -108,6 +110,7 @@ jobs:
|
||||
T3CODE_PERF_MAX_LONG_DISPATCH_COUNT: "5"
|
||||
T3CODE_DESKTOP_PERF_RUN_TERMINAL: "0"
|
||||
T3CODE_DESKTOP_PERF_RUN_OPTIONAL_RENDERER: "0"
|
||||
T3CODE_DESKTOP_PERF_RUN_BENCHMARK_SWEEP: "0"
|
||||
T3CODE_DESKTOP_PERF_BENCHMARK_FOLLOW_UP_PASSES: "0"
|
||||
T3CODE_ELECTRON_STARTUP_TIMEOUT_MS: "180000"
|
||||
run: xvfb-run -a bun run test:desktop-perf:post
|
||||
|
||||
@@ -6,6 +6,7 @@ import path from "node:path";
|
||||
import { BrowserWindow, contentTracing, type WebContents } from "electron";
|
||||
import {
|
||||
resolveBenchmarkFollowUpPassCount,
|
||||
shouldRunBenchmarkThreadSweep,
|
||||
shouldRunOptionalRendererPerfInteractions,
|
||||
shouldRunTerminalPerfInteractions,
|
||||
} from "./perfConfig";
|
||||
@@ -27,6 +28,10 @@ const BENCHMARK_FOLLOW_UP_PASS_COUNT = resolveBenchmarkFollowUpPassCount({
|
||||
process.env.T3CODE_DESKTOP_PERF_BENCHMARK_FOLLOW_UP_PASSES,
|
||||
CI: process.env.CI,
|
||||
});
|
||||
const RUN_BENCHMARK_THREAD_SWEEP = shouldRunBenchmarkThreadSweep({
|
||||
T3CODE_DESKTOP_PERF_RUN_BENCHMARK_SWEEP: process.env.T3CODE_DESKTOP_PERF_RUN_BENCHMARK_SWEEP,
|
||||
CI: process.env.CI,
|
||||
});
|
||||
|
||||
function delay(ms: number): Promise<void> {
|
||||
return new Promise((resolve) => setTimeout(resolve, ms));
|
||||
@@ -575,13 +580,14 @@ async function runRendererPerfInteractions(
|
||||
return Number((sorted[middle] ?? 0).toFixed(2));
|
||||
};
|
||||
|
||||
const runBenchmarkThreadSweep = ${RUN_BENCHMARK_THREAD_SWEEP};
|
||||
const preferredThreadIds = ${JSON.stringify(benchmarkThreadIds)}.filter(
|
||||
(value) => typeof value === "string" && value.length > 0,
|
||||
);
|
||||
const benchmarkThreadIds = preferredThreadIds.filter((threadId) =>
|
||||
renderedThreadIds.includes(threadId),
|
||||
);
|
||||
if (benchmarkThreadIds.length === 0) {
|
||||
const benchmarkThreadIds = runBenchmarkThreadSweep
|
||||
? preferredThreadIds.filter((threadId) => renderedThreadIds.includes(threadId))
|
||||
: [];
|
||||
if (runBenchmarkThreadSweep && benchmarkThreadIds.length === 0) {
|
||||
benchmarkThreadIds.push(...renderedThreadIds.slice(0, ${BENCHMARK_THREAD_COUNT}));
|
||||
}
|
||||
|
||||
@@ -599,25 +605,27 @@ async function runRendererPerfInteractions(
|
||||
};
|
||||
|
||||
const firstPassByThreadId = new Map();
|
||||
for (const threadId of benchmarkThreadIds) {
|
||||
await ensureThreadSwitchTarget(threadId);
|
||||
firstPassByThreadId.set(threadId, await measureThreadRender(threadId));
|
||||
}
|
||||
|
||||
const followUpSamplesByThreadId = new Map();
|
||||
for (const threadId of benchmarkThreadIds) {
|
||||
followUpSamplesByThreadId.set(threadId, []);
|
||||
}
|
||||
const followUpPassCount = ${BENCHMARK_FOLLOW_UP_PASS_COUNT};
|
||||
for (let passIndex = 0; passIndex < followUpPassCount; passIndex += 1) {
|
||||
if (runBenchmarkThreadSweep) {
|
||||
for (const threadId of benchmarkThreadIds) {
|
||||
await ensureThreadSwitchTarget(threadId);
|
||||
const sample = await measureThreadRender(threadId);
|
||||
const samples = followUpSamplesByThreadId.get(threadId);
|
||||
if (Array.isArray(samples)) {
|
||||
samples.push(sample.renderMs);
|
||||
} else {
|
||||
followUpSamplesByThreadId.set(threadId, [sample.renderMs]);
|
||||
firstPassByThreadId.set(threadId, await measureThreadRender(threadId));
|
||||
}
|
||||
|
||||
for (const threadId of benchmarkThreadIds) {
|
||||
followUpSamplesByThreadId.set(threadId, []);
|
||||
}
|
||||
const followUpPassCount = ${BENCHMARK_FOLLOW_UP_PASS_COUNT};
|
||||
for (let passIndex = 0; passIndex < followUpPassCount; passIndex += 1) {
|
||||
for (const threadId of benchmarkThreadIds) {
|
||||
await ensureThreadSwitchTarget(threadId);
|
||||
const sample = await measureThreadRender(threadId);
|
||||
const samples = followUpSamplesByThreadId.get(threadId);
|
||||
if (Array.isArray(samples)) {
|
||||
samples.push(sample.renderMs);
|
||||
} else {
|
||||
followUpSamplesByThreadId.set(threadId, [sample.renderMs]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ import { describe, expect, it } from "vitest";
|
||||
|
||||
import {
|
||||
resolveBenchmarkFollowUpPassCount,
|
||||
shouldRunBenchmarkThreadSweep,
|
||||
shouldRunOptionalRendererPerfInteractions,
|
||||
shouldRunTerminalPerfInteractions,
|
||||
} from "./perfConfig";
|
||||
@@ -207,3 +208,25 @@ describe("shouldRunOptionalRendererPerfInteractions", () => {
|
||||
).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe("shouldRunBenchmarkThreadSweep", () => {
|
||||
it("defaults to enabled outside CI and disabled in CI", () => {
|
||||
expect(shouldRunBenchmarkThreadSweep({ CI: "false" })).toBe(true);
|
||||
expect(shouldRunBenchmarkThreadSweep({ CI: "true" })).toBe(false);
|
||||
});
|
||||
|
||||
it("supports explicit env overrides", () => {
|
||||
expect(
|
||||
shouldRunBenchmarkThreadSweep({
|
||||
T3CODE_DESKTOP_PERF_RUN_BENCHMARK_SWEEP: "1",
|
||||
CI: "true",
|
||||
}),
|
||||
).toBe(true);
|
||||
expect(
|
||||
shouldRunBenchmarkThreadSweep({
|
||||
T3CODE_DESKTOP_PERF_RUN_BENCHMARK_SWEEP: "off",
|
||||
CI: "false",
|
||||
}),
|
||||
).toBe(false);
|
||||
});
|
||||
});
|
||||
@@ -13,6 +13,11 @@ type PerfBenchmarkEnv = {
|
||||
CI?: string | undefined;
|
||||
};
|
||||
|
||||
type BenchmarkSweepToggleEnv = {
|
||||
T3CODE_DESKTOP_PERF_RUN_BENCHMARK_SWEEP?: string | undefined;
|
||||
CI?: string | undefined;
|
||||
};
|
||||
|
||||
const TRUE_VALUES = new Set(["1", "true", "yes", "on"]);
|
||||
const FALSE_VALUES = new Set(["0", "false", "no", "off"]);
|
||||
const MAX_BENCHMARK_FOLLOW_UP_PASSES = 5;
|
||||
@@ -52,6 +57,12 @@ export function shouldRunOptionalRendererPerfInteractions(env: OptionalRendererT
|
||||
return !isCiEnvironment(env.CI);
|
||||
}
|
||||
|
||||
export function shouldRunBenchmarkThreadSweep(env: BenchmarkSweepToggleEnv): boolean {
|
||||
const toggleOverride = parseBooleanLike(env.T3CODE_DESKTOP_PERF_RUN_BENCHMARK_SWEEP);
|
||||
if (toggleOverride !== null) return toggleOverride;
|
||||
return !isCiEnvironment(env.CI);
|
||||
}
|
||||
|
||||
export function resolveBenchmarkFollowUpPassCount(env: PerfBenchmarkEnv): number {
|
||||
const raw = env.T3CODE_DESKTOP_PERF_BENCHMARK_FOLLOW_UP_PASSES?.trim();
|
||||
if (raw && /^\d+$/.test(raw)) {
|
||||
|
||||
Reference in new issue
Block a user