History

Add CI toggle to skip benchmark thread sweep

Cursor Agent committed 9 months ago

Commit d69f0551 parent b3460f64 files · +65 −20Browse files

Unified · Split

4 files
  1. .github/workflows/ci.yml +3 −0
  2. apps/desktop/src/desktopPerfAutomation.ts +28 −20
  3. apps/desktop/src/perfConfig.test.ts +23 −0
  4. apps/desktop/src/perfConfig.ts +11 −0
.github/workflows/ci.yml+3−0
@@ -83,6 +83,7 @@ jobs: · 82 unmodified lines
8383 # Terminal PTY scripting is flaky in CI VMs; renderer perf checks remain enforced.
8484 T3CODE_DESKTOP_PERF_RUN_TERMINAL: "0"
8585 T3CODE_DESKTOP_PERF_RUN_OPTIONAL_RENDERER: "0"
86+ T3CODE_DESKTOP_PERF_RUN_BENCHMARK_SWEEP: "0"
8687 T3CODE_DESKTOP_PERF_BENCHMARK_FOLLOW_UP_PASSES: "0"
8788 T3CODE_ELECTRON_STARTUP_TIMEOUT_MS: "180000"
8889 run: xvfb-run -a bun run test:desktop-perf
@@ -95,6 +96,7 @@ jobs: · 6 unmodified lines
9596 T3CODE_PERF_MAX_LONG_DISPATCH_COUNT: "5"
9697 T3CODE_DESKTOP_PERF_RUN_TERMINAL: "0"
9798 T3CODE_DESKTOP_PERF_RUN_OPTIONAL_RENDERER: "0"
99+ T3CODE_DESKTOP_PERF_RUN_BENCHMARK_SWEEP: "0"
98100 T3CODE_DESKTOP_PERF_BENCHMARK_FOLLOW_UP_PASSES: "0"
99101 T3CODE_ELECTRON_STARTUP_TIMEOUT_MS: "180000"
100102 run: xvfb-run -a bun run test:desktop-perf
@@ -108,6 +110,7 @@ jobs: · 7 unmodified lines
108110 T3CODE_PERF_MAX_LONG_DISPATCH_COUNT: "5"
109111 T3CODE_DESKTOP_PERF_RUN_TERMINAL: "0"
110112 T3CODE_DESKTOP_PERF_RUN_OPTIONAL_RENDERER: "0"
113+ T3CODE_DESKTOP_PERF_RUN_BENCHMARK_SWEEP: "0"
111114 T3CODE_DESKTOP_PERF_BENCHMARK_FOLLOW_UP_PASSES: "0"
112115 T3CODE_ELECTRON_STARTUP_TIMEOUT_MS: "180000"
113116 run: xvfb-run -a bun run test:desktop-perf:post
apps/desktop/src/desktopPerfAutomation.ts+28−20
@@ -6,6 +6,7 @@ import path from "node:path"; · 5 unmodified lines
66 import { BrowserWindow, contentTracing, type WebContents } from "electron";
77 import {
88 resolveBenchmarkFollowUpPassCount,
9+ shouldRunBenchmarkThreadSweep,
910 shouldRunOptionalRendererPerfInteractions,
1011 shouldRunTerminalPerfInteractions,
1112 } from "./perfConfig";
@@ -27,6 +28,10 @@ const BENCHMARK_FOLLOW_UP_PASS_COUNT = resolveBenchmarkFollowUpPassCount({ · 15 unmodified lines
2728 process.env.T3CODE_DESKTOP_PERF_BENCHMARK_FOLLOW_UP_PASSES,
2829 CI: process.env.CI,
2930 });
31+const RUN_BENCHMARK_THREAD_SWEEP = shouldRunBenchmarkThreadSweep({
32+ T3CODE_DESKTOP_PERF_RUN_BENCHMARK_SWEEP: process.env.T3CODE_DESKTOP_PERF_RUN_BENCHMARK_SWEEP,
33+ CI: process.env.CI,
34+});
3035
3136 function delay(ms: number): Promise<void> {
3237 return new Promise((resolve) => setTimeout(resolve, ms));
@@ -575,13 +580,14 @@ async function runRendererPerfInteractions( · 542 unmodified lines
575580 return Number((sorted[middle] ?? 0).toFixed(2));
576581 };
577582
583+ const runBenchmarkThreadSweep = ${RUN_BENCHMARK_THREAD_SWEEP};
578584 const preferredThreadIds = ${JSON.stringify(benchmarkThreadIds)}.filter(
579585 (value) => typeof value === "string" && value.length > 0,
580586 );
581− const benchmarkThreadIds = preferredThreadIds.filter((threadId) =>
582− renderedThreadIds.includes(threadId),
583− );
584− if (benchmarkThreadIds.length === 0) {
587+ const benchmarkThreadIds = runBenchmarkThreadSweep
588+ ? preferredThreadIds.filter((threadId) => renderedThreadIds.includes(threadId))
589+ : [];
590+ if (runBenchmarkThreadSweep && benchmarkThreadIds.length === 0) {
585591 benchmarkThreadIds.push(...renderedThreadIds.slice(0, ${BENCHMARK_THREAD_COUNT}));
586592 }
587593
@@ -599,25 +605,27 @@ async function runRendererPerfInteractions( · 11 unmodified lines
599605 };
600606
601607 const firstPassByThreadId = new Map();
602− for (const threadId of benchmarkThreadIds) {
603− await ensureThreadSwitchTarget(threadId);
604− firstPassByThreadId.set(threadId, await measureThreadRender(threadId));
605− }
606−
607608 const followUpSamplesByThreadId = new Map();
608− for (const threadId of benchmarkThreadIds) {
609− followUpSamplesByThreadId.set(threadId, []);
610− }
611− const followUpPassCount = ${BENCHMARK_FOLLOW_UP_PASS_COUNT};
612− for (let passIndex = 0; passIndex < followUpPassCount; passIndex += 1) {
609+ if (runBenchmarkThreadSweep) {
613610 for (const threadId of benchmarkThreadIds) {
614611 await ensureThreadSwitchTarget(threadId);
615− const sample = await measureThreadRender(threadId);
616− const samples = followUpSamplesByThreadId.get(threadId);
617− if (Array.isArray(samples)) {
618− samples.push(sample.renderMs);
619− } else {
620− followUpSamplesByThreadId.set(threadId, [sample.renderMs]);
612+ firstPassByThreadId.set(threadId, await measureThreadRender(threadId));
613+ }
614+
615+ for (const threadId of benchmarkThreadIds) {
616+ followUpSamplesByThreadId.set(threadId, []);
617+ }
618+ const followUpPassCount = ${BENCHMARK_FOLLOW_UP_PASS_COUNT};
619+ for (let passIndex = 0; passIndex < followUpPassCount; passIndex += 1) {
620+ for (const threadId of benchmarkThreadIds) {
621+ await ensureThreadSwitchTarget(threadId);
622+ const sample = await measureThreadRender(threadId);
623+ const samples = followUpSamplesByThreadId.get(threadId);
624+ if (Array.isArray(samples)) {
625+ samples.push(sample.renderMs);
626+ } else {
627+ followUpSamplesByThreadId.set(threadId, [sample.renderMs]);
628+ }
621629 }
622630 }
623631 }
apps/desktop/src/perfConfig.test.ts+23−0
@@ -2,6 +2,7 @@ import { describe, expect, it } from "vitest"; · 1 unmodified line
22
33 import {
44 resolveBenchmarkFollowUpPassCount,
5+ shouldRunBenchmarkThreadSweep,
56 shouldRunOptionalRendererPerfInteractions,
67 shouldRunTerminalPerfInteractions,
78 } from "./perfConfig";
@@ -207,3 +208,25 @@ describe("shouldRunOptionalRendererPerfInteractions", () => { · 199 unmodified lines
207208 ).toBe(false);
208209 });
209210 });
211+
212+describe("shouldRunBenchmarkThreadSweep", () => {
213+ it("defaults to enabled outside CI and disabled in CI", () => {
214+ expect(shouldRunBenchmarkThreadSweep({ CI: "false" })).toBe(true);
215+ expect(shouldRunBenchmarkThreadSweep({ CI: "true" })).toBe(false);
216+ });
217+
218+ it("supports explicit env overrides", () => {
219+ expect(
220+ shouldRunBenchmarkThreadSweep({
221+ T3CODE_DESKTOP_PERF_RUN_BENCHMARK_SWEEP: "1",
222+ CI: "true",
223+ }),
224+ ).toBe(true);
225+ expect(
226+ shouldRunBenchmarkThreadSweep({
227+ T3CODE_DESKTOP_PERF_RUN_BENCHMARK_SWEEP: "off",
228+ CI: "false",
229+ }),
230+ ).toBe(false);
231+ });
232+});
apps/desktop/src/perfConfig.ts+11−0
@@ -13,6 +13,11 @@ type PerfBenchmarkEnv = { · 12 unmodified lines
1313 CI?: string | undefined;
1414 };
1515
16+type BenchmarkSweepToggleEnv = {
17+ T3CODE_DESKTOP_PERF_RUN_BENCHMARK_SWEEP?: string | undefined;
18+ CI?: string | undefined;
19+};
20+
1621 const TRUE_VALUES = new Set(["1", "true", "yes", "on"]);
1722 const FALSE_VALUES = new Set(["0", "false", "no", "off"]);
1823 const MAX_BENCHMARK_FOLLOW_UP_PASSES = 5;
@@ -52,6 +57,12 @@ export function shouldRunOptionalRendererPerfInteractions(env: OptionalRendererT · 33 unmodified lines
5257 return !isCiEnvironment(env.CI);
5358 }
5459
60+export function shouldRunBenchmarkThreadSweep(env: BenchmarkSweepToggleEnv): boolean {
61+ const toggleOverride = parseBooleanLike(env.T3CODE_DESKTOP_PERF_RUN_BENCHMARK_SWEEP);
62+ if (toggleOverride !== null) return toggleOverride;
63+ return !isCiEnvironment(env.CI);
64+}
65+
5566 export function resolveBenchmarkFollowUpPassCount(env: PerfBenchmarkEnv): number {
5667 const raw = env.T3CODE_DESKTOP_PERF_BENCHMARK_FOLLOW_UP_PASSES?.trim();
5768 if (raw && /^\d+$/.test(raw)) {

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t