Skip to content

[CI] Reduce import, frame-capture, teardown, and shard costs - #28879

Merged
nwparker merged 10 commits into
mainfrom
nwparker/ci-runner-occupancy
Oct 15, 2026
Merged

nwparker merged 10 commits into
mainfrom
nwparker/ci-runner-occupancy

Conversation

@nwparker

@nwparker nwparker commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 37 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​1324 $\color{#cf222e}{\Huge{\mathbf{−}}}$​348 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​976
Prod 20 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​13394 $\color{#cf222e}{\Huge{\mathbf{−}}}$​11706 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​1688

ELI5

CI spends less time loading unrelated code, waiting for hidden browser frames, and holding processes open after a test. The runner types, shard counts, and capacity stay the same. Hosted checks will determine the net runner-time improvement.

What Changed

  • Reuse acknowledged hidden-renderer capture for popup probes and attach CDP before creating guest views. All 39 cases retain their input, assertions, security checks, and deadlines.
  • Start final daemon cleanup after confirmed app exit while still awaiting Playwright's public close. This releases sockets inherited by Linux daemon children; restart paths retain daemon persistence.
  • Overlap relay SQLite tests with the single-worker PostgreSQL project within the existing CPU budget. Other Cloud packages finish first, and selectors, alternate databases, or small CPUs retain sequential execution. Resume the lost-reply proxy before the final identity query while preserving its 6.5-second simulated stall.
  • Use explicit mocks and the existing guarded registry fixture to avoid importing unused modules in 14 suites. Remove 11 cosmetic/default-copy cases and their preview snapshot. Skip five Windows-only paste cases before launching an app on other platforms.
  • Prepare Electron natives in the completed app-build job, saving Node natives before switching ABI. Preserve independent PR-head and merge-source builds and consumer validation/fallbacks. Disable Playwright's automatic Git diff metadata collection; CI's source identity remains recorded.
  • Refresh unit scheduling weights from all five qualified ARM shards, replacing estimates for 739 previously unmeasured current files. Preserve the existing algorithm, workers, capacity, selection, and E2E weights. The generated timing data accounts for most changed non-test lines; projected balance is not a hosted speed claim.
  • Replace the delivery-model harness’s unasserted RPC spy with the same plain async function, preserving every schedule, fault, and delivery assertion.
  • Add a manually dispatched full-suite transform-cache comparison with baseline, cold producer, and warm phases. Ordinary CI caching remains off. Exact identities, bounded contents, hashes, metadata validation, and cold fallback protect reuse; producer/upload/restore costs are included in its evaluation.

Why

Measurements identify fixture waits, unrelated imports, and duplicate setup as substantial costs. Reusing existing capture, cleanup, registry, and process-host implementations keeps the changes narrow and preserves behavior checks. Caching needs a successful same-source full-suite comparison before it can become a normal CI policy.

Linked Issue

N/A — internal CI maintenance.

Visual Proof

N/A — no product layout or interaction changes. Hidden-renderer screenshots and presentation-call records were inspected during fixture validation.

Testing

  • I manually tested these changes locally
  • Automated tests added/updated, or explained why not below

All figures below are local evidence, not hosted runner savings:

Measurement Before After
Popup probes, isolated Linux with CI runtimes, 39 cases in parallel 283.79s 22.81s
Linux final app close, with nearly identical root-exit timing 10.004s fallback 1.541s public close
Full Cloud command, existing 2,927 passes + one skip retained 326.42s 283.99s
Nine explicit-registry suites, 107 cases, Bun summed module median 15.554s 8.193s
Two startup suites, nine cases, Bun summed module median 2.974s 0.280s
Two Monaco suites, four cases, Bun summed module median 1.934s 0.718s

Popup validation also passed 39 cases twice on macOS, plus an independent serial 39-case run matching packaging's file policy (46.55s). Linux trace/video outputs validate and decode; final cleanup leaves no owned processes, sockets, Playwright scratch directories, or profiles. Warm-restart scrollback passes on Linux and macOS. Cloud adds 16 runner contracts; the separate lost-reply fix reduces its four-case suite from 17.52s to 10.97s and is not included in the full-command result above. Counterbalanced import comparisons retain byte-identical case bodies; Node comparisons also pass.

A serial local delivery-model comparison retained 228 MiB less heap after GC with the same 10 cases, 2,000 schedules, 120,000 steps, and 75,191,101 PTY bytes. The timing difference was only about 75 ms; no material runtime or hosted saving is claimed.

Full root typecheck, changed-code quality and focused lint/format pass. Cloud typecheck/build stages and independent reviews pass. The scheduling importer/sequencer/planner contracts pass 32 cases; all 375 cases across the 12 script suites referencing the affected workflows pass. Upload always starts before foreground native preparation, followed by a bare wait; older-ref fallback is preserved. Normal PRs retain default-enabled relay integration, with explicit opt-out confined to manual comparisons. Full E2E typecheck has existing errors outside the changed files.

Hosted qualification for exact head d5f647565852ab49fc789e79e96bb48b86813f02: PR run 38655504365, source 2f446371e395b8c6525b92dfe25663a676848bf9, five successful head workflows and all 50 checks complete (29 success, 21 expected skips). The full PR aggregate passes. Original ZIP hashes, all 20 unit reports, exact merge parents, independent source inventory and recomputed assignments are verified: 12,171 passed modules, 151 skipped, zero errors, full 12,322-file coverage. All 12,312 common modules retain their prior status; ten passed modules were added and four documented cosmetic modules removed.

Inclusive runner occupancy First green #28669 This green head
Five full unit shards 50.73 min 48.70 min
Linux + Windows package jobs 18.60 min 12.73 min
Units + packages 69.33 min 61.43 min

The combined observation is 7.90 runner-minutes lower (11.39%). It includes setup, native preparation, caches, uploads and post steps, at unchanged capacity. Package commands, all 78 test-file blobs, case counts and skips match; Linux retains all nine moved Electron suites. Historical source/workload, unit images and cache warmth differ, so this is not an isolated causal measurement. The original 48.57-minute unit baseline is only 0.13 minute below this result. The selected auxiliary workflows and E2E specs differ; their unadjusted totals are not counted as comparable savings. Ordinary transform caching remains off pending the manual same-source comparison.

Review

Independent reviews checked assertions, hidden-window policy, cleanup/persistence, native ABI ordering, cache validation, workflow routing, and cross-platform/remote assumptions. Full unit selection remains enabled.

Deliberately removed coverage: Pull/Sync/Publish icon choices, conflict-warning wrapping, default-font summary wording, and exact preview demo text/ANSI/final cursor placement. Commit actions, warning generation/localization, selected-language summaries, preview lifecycle, and real Monaco setup/ownership retain coverage. The two mocked-editor suites no longer incidentally load real Monaco setup.

Agent skill upstream boundary

  • Not applicable, or this change copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.

Checklist

  • This PR is small and focused
  • I explained what changed and why (ELI5, the user-facing before/after, the mechanism, and why over the alternatives)
  • Before/after screenshots or videos attached for UI changes, or N/A with reason
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and path/shortcut impact considered (or N/A)
  • pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass (or CI will cover; local preferred)

@nwparker
nwparker requested a review from Jinwoo-H as a code owner October 14, 2026 23:16
@coderabbitai

coderabbitai Bot commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

📝 Walkthrough

The pull request adds module-cache identity, validation, sealing, and optional unit-phase diagnostics to unit-test workflows. It revises E2E native dependency setup and removes the separate native-cache preparation job. Cloud relay tests gain a process-aware runner and updated package wiring. Browser popup fixtures share HTML and frame-capture helpers, while Electron E2E helpers coordinate daemon cleanup and record timing. Other changes adjust test setup, platform gating, and Playwright metadata.

Priority: ➖ Normal

Merge Risk: ⚪ Minimal · up to d5f64

Relay integration remains enabled for the current callers. The review recommends extending the test to protect the compatibility caller from a future override; no current behavior defect remains.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 4.88% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 41 functions across 42 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Title check Passed The title clearly summarizes the main changes: reducing CI costs across imports, frame capture, teardown, and shard execution.
Description check Passed The description is complete and detailed. It covers the required explanation, changes, rationale, issue context, visual proof, testing evidence, review notes, compatibility considerations, and checkli…
  • Fix all pre-merge checks with AI
✨ Finishing Touches: 💡 1
📝 Generate docstrings: 💡
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments: 1
config/scripts/ci-unit-module-cache.mjs: 1

216-216: 🩺 Stability & Availability | 🔵 Trivial | 💤 Low value

Make the prepare and seal phases tolerate a missing identity report.

The identity phase catches its errors and only logs a warning. If it fails, the workflow skips the later steps, because the key output is empty. However, a failed bun lookup or a hashing error can still happen after output() writes the key. In that case, Line 216 throws an unhandled error while it reads IDENTITY_REPORT, and the shard fails. The risk is small, because writeAssignment runs before output. Still, the prepare and seal phases are optional cache work. An unhandled read error in either phase must not fail the test job.

Proposed fix
-    const identity = JSON.parse(readFileSync(IDENTITY_REPORT, 'utf8'))
+    let identity
+    try {
+      identity = JSON.parse(readFileSync(IDENTITY_REPORT, 'utf8'))
+    } catch (error) {
+      console.warn(`Unit module cache identity unavailable: ${String(error)}`)
+      process.exit(0)
+    }

ℹ️ Review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 5692b33e-2718-49ea-8da0-db2b75ebcecd
📥 Commits

Reviewing files that changed from the base of the PR and between 818e782 and e8cb134.

⛔ Files ignored due to path filters: 2
  • cloud/pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
  • src/renderer/src/components/settings/__snapshots__/terminal-preview-content.test.ts.snap is excluded by !**/*.snap
📒 Files selected for processing: 54
  • .github/workflows/cloud-verify.yml
  • .github/workflows/e2e.yml
  • .github/workflows/unit-module-cache-benchmark.yml
  • .github/workflows/unit-tests.yml
  • cloud/apps/relay/package.json
  • cloud/apps/relay/src/postgres-lost-reply-postgres.test.ts
  • cloud/apps/relay/vitest.config.ts
  • cloud/dev/scripts/run-relay-tests.mjs
  • cloud/dev/scripts/run-relay-tests.test.mjs
  • cloud/package.json
  • config/scripts/ci-e2e-job-selection.test.mjs
  • config/scripts/ci-native-cache.test.mjs
  • config/scripts/ci-shard-timings.json
  • config/scripts/ci-shard-timings.md
  • config/scripts/ci-unit-module-cache-contents.mjs
  • config/scripts/ci-unit-module-cache-contents.test.mjs
  • config/scripts/ci-unit-module-cache-trailer.mjs
  • config/scripts/ci-unit-module-cache.mjs
  • config/scripts/ci-unit-module-cache.test.mjs
  • config/scripts/ci-unit-timing-reporter.mjs
  • config/scripts/ci-unit-timing-reporter.test.mjs
  • config/scripts/orcad-e2e-routing.test.mjs
  • config/scripts/release-cut-token-permissions.test.mjs
  • config/vitest.config.ts
  • src/main/browser/browser-popup-compatibility-cdp-fixture.ts
  • src/main/browser/browser-popup-compatibility-electron-fixture.ts
  • src/main/browser/browser-popup-compatibility-page-fixture.ts
  • src/main/browser/hidden-renderer-frame-capture-fixture.ts
  • src/main/runtime/mobile-subscribe-idle-pane-hydrate.test.ts
  • src/main/runtime/opencode-wsl-folder-launch-host.test.ts
  • src/main/runtime/rpc/dispatcher-transport-parity.test.ts
  • src/main/runtime/rpc/methods/agent-launch-restart-replay.test.ts
  • src/main/runtime/rpc/methods/managed-server.test.ts
  • src/main/runtime/rpc/methods/mobile-web-bundle-read-concurrency.test.ts
  • src/main/runtime/rpc/methods/mobile-web-bundle-window-refusals.test.ts
  • src/main/runtime/rpc/methods/mobile-web-bundle.test.ts
  • src/main/runtime/rpc/methods/structured-agent-session-attachments.test.ts
  • src/main/runtime/rpc/orchestration-legacy-compatibility-dispatcher.test.ts
  • src/main/startup/codex-hook-startup-wiring.test.ts
  • src/main/startup/main-process-runtime-launch-activation.test.ts
  • src/renderer/src/components/editor/MonacoEditor.font-family.test.tsx
  • src/renderer/src/components/editor/MonacoEditor.system-theme.test.tsx
  • src/renderer/src/components/right-sidebar/CommitArea.primary-icons.test.tsx
  • src/renderer/src/components/settings/ShortcutCommandBlock.test.tsx
  • src/renderer/src/components/settings/appearance-interface-summary.test.ts
  • src/renderer/src/components/settings/terminal-preview-content.test.ts
  • tests/e2e/helpers/electron-process-shutdown.ts
  • tests/e2e/helpers/electron-process-shutdown.unit.test.ts
  • tests/e2e/helpers/electron-shutdown-timing.ts
  • tests/e2e/helpers/hidden-renderer-frame-capture.ts
  • tests/e2e/helpers/orca-app.ts
  • tests/e2e/remote-terminal-input-delivery-model.unit.test.ts
  • tests/e2e/terminal-windows-shell-paste-ownership.spec.ts
  • tests/playwright.config.ts
💤 Files with no reviewable changes: 5
  • src/renderer/src/components/settings/ShortcutCommandBlock.test.tsx
  • src/renderer/src/components/right-sidebar/CommitArea.primary-icons.test.tsx
  • src/renderer/src/components/settings/terminal-preview-content.test.ts
  • config/scripts/release-cut-token-permissions.test.mjs
  • src/renderer/src/components/settings/appearance-interface-summary.test.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments: 1
config/scripts/pr-auxiliary-preflight-admission.test.mjs: 1

251-263: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win

Cover node-next-compat.yml in the relay-default assertion.

node-next-compat.yml is an ordinary unit-test caller. It invokes unit-tests.yml without run_relay_integration, so a future false override could skip its relay tests while this admission test still passes because it checks only pr.yml.

Suggested fix
 const workflow = parse(readFileSync('.github/workflows/pr.yml', 'utf8'))
 const unit = parse(readFileSync('.github/workflows/unit-tests.yml', 'utf8'))
+const nodeNextCompat = parse(readFileSync('.github/workflows/node-next-compat.yml', 'utf8'))
@@
     expect(
       evaluate(unit.jobs.relay_integration.if, { inputs: { run_relay_integration: false } })
     ).toBe(false)
     expect(workflow.jobs.test.with.run_relay_integration).toBeUndefined()
+    expect(nodeNextCompat.jobs.test.with.run_relay_integration).toBeUndefined()
     expect(unit.jobs.relay_integration.needs).toBeUndefined()

ℹ️ Review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 171caa41-facc-432e-8349-a04681f11452
📥 Commits

Reviewing files that changed from the base of the PR and between e8cb134 and d5f6475.

📒 Files selected for processing: 1
  • config/scripts/pr-auxiliary-preflight-admission.test.mjs

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 6 remain after this review.

@nwparker
nwparker merged commit 39815a0 into main Oct 15, 2026
50 checks passed
@nwparker nwparker changed the title Reduce CI import, frame-capture, teardown, and shard costs [CI] Reduce import, frame-capture, teardown, and shard costs Oct 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant