Skip to content

Latest commit

 

History

History
145 lines (119 loc) · 8.63 KB

PERFORMANCE-CHECKS.md

File metadata and controls

145 lines (119 loc) · 8.63 KB

Local Electron performance checks

Run from the repository root after installing dependencies and building the app:

pnpm build
node apps/desktop/scripts/verify-performance.js 3

The gate uses three independent renderer samples and three cold app starts. It opens isolated test windows, chooses unused loopback ports, and uses temporary data folders. It does not restart the shared development stack or run hosted CI. A custom report folder can be passed as the last argument.

The visible fixture renders the real thread component at 1180 by 820 pixels, visits all 500 messages, applies at least 1,000 streamed deltas, and switches among five task stores. The gate checks the first paint, frame times, delta batch work, session switches, cold startup, and idle memory against the architecture budgets.

Idle memory includes all processes returned by Electron's app metrics. On macOS, the measurement uses the OS physical footprint for every process and retains summed RSS too. Other platforms use working-set bytes. A missing footprint falls back to the larger working-set accounting for that process; missing or zero data fails the gate.

The cold-start clock still measures the first usable screen. Idle memory starts only once its startup RPCs (including model loading and update checks) have completed, temporary startup notices have finished their exits, and the two-second quiet delay has elapsed. New requests restart that delay; a request during capture fails the sample. The outer process timeout includes the existing 15-second startup allowance, the quiet delay, and the separate ten-second memory capture deadline. It does not retry a failed capture.

GPU resources can retire several seconds after the final paint. Idle measurement waits for four samples whose capture starts are at least one second apart with the same process identities and at most 2% variation across the whole window. Every sample in that window must be below 500,000,000 bytes. The wait ends after ten seconds and fails if memory does not settle. OS read time is included in the sampling interval, so a slow read does not add another full second of delay. The report retains every sample and the transient peak. It does not force garbage collection, unload the page, purge caches, or change GPU flags.

After the idle capture, a fresh window mounts one finished turn with 300 tool calls and 37.5 MiB of plain, command and JSON output, collapsed, over a store that already holds that text. The main process reads the heap through Chromium's debugger after three forced garbage collections between steps. The collapsed activity must stay below 200 elements and add less than 8 MiB of heap; opening it must mount 300 rows and exactly the one output that was opened. One open and close warms up first-open costs such as lazily loaded code; after a second close no row or output may remain and the heap must stay less than 2 MiB above the reading taken before that second open. On Linux with Electron 43 the collapsed activity added 1.4 MiB; mounting every output while collapsed, as before #1013, added 29 MiB and 4,707 elements. The fixture opens its own window, so the memory figures above stay unchanged.

Keep the machine otherwise quiet during measurement. A failure is a failed check; inspect the full report before drawing a conclusion. Run this on each release OS. Unit tests cover the accounting and thresholds; they do not replace real Electron measurements.

The same command first renders two identical 700-line TypeScript fences through the production CompletedMarkdown component and native syntax worker. It requires one highlight request, colored tokens, no additional request on remount or light/dark changes, and distinct computed token colors in both themes. It waits for every token batch and verifies both complete 700-line sources and nonzero line layout after bringing each fence into view. Foreground inheritance can reduce the number of colored DOM spans without dropping source tokens or changing their colors. The fixture observes the native worker's postMessage calls; it does not replace worker execution or synthesize tokens. It opens a fresh sandboxed window before the existing thread gate to avoid warming that gate's caches and avoid intermittent animation-frame stalls after reloading the traced page.

Each renderer-N.json includes highlighting frame samples and observed long-task durations; both must stay below the existing 32 ms frame budget. Chromium's long-task observer only reports tasks of at least 50 ms, so the runner also fails any main-thread trace task at or above 32 ms overlapping the measured highlighting interval, including tasks that begin just before the first mark. Missing renderer, worker or mark evidence fails the gate. Inspect the accompanying renderer-N.json.highlighting-trace.json in Chromium's trace viewer to verify renderer/worker attribution and tasks around the highlight-cold-* and highlight-remount-* marks. Traces are captured with Electron's contentTracing API. Record the tested commit, OS, architecture and all three reports with acceptance evidence. Compilation and threshold unit tests are not a passing production trace. Do not disable the browser sandbox to run this gate.

To verify trusted preview height limits, capture cancellation, and storage cleanup using real Electron windows and the real preload bridge:

node apps/desktop/scripts/verify-preview.js

Reports go to apps/desktop/performance-results/ and apps/desktop/preview-results/ by default. Both folders are ignored by Git.

Release size

The window and syntax worker share one build of the shipped grammar data. They still load languages on demand and keep separate parser state. The build test compares every emitted language with the original module and checks imports from both consumers:

pnpm --filter @harness/web exec vitest run scripts/shared-grammars.test.ts src/ui/shiki-bundle.test.ts

The theme patch retains the four GitHub themes used by chat and diffs, plus the full Pierre default collection. Keep its catalog aligned with actual theme use when updating the dependency. Fonts, glyph coverage and design reference images remain complete.

Desktop packaging excludes build inputs, debug maps, type-only generated modules, test helpers and unused dependency formats. After changing those exclusions, run the packaged native proof on each release OS. It imports every adapter and the HTML preview parser before checking the terminal and keyring, so source tests alone cannot hide a missing release dependency:

node apps/desktop/scripts/run-native-binding-proof.js <app-or-exe>

Keep the platform's terminal prebuilds: pruning by architecture also changes the inputs to universal Mac packaging. Windows packages leave out node-pty's ConPTY copies that the prebuilt module never loads: the install-time third_party sources and the post-install copy in build/Release/conpty. Each prebuild keeps its own conpty folder. Keep Electron's GPU fallback, media, locale data and startup files. Installer compression changes download size, not installed size. ZIP files use maximum compression; DMGs keep the existing UDZO format so the size setting does not switch disk-image opening to bzip2 decompression.

Pull-request image previews

Targeted regressions cover authenticated uploads, binary output limits, image formats, relative paths, SVG isolation, visibility-gated loading, request deduplication, and byte-bounded caches:

pnpm --filter @harness/server exec vitest run src/pull-request-images.test.ts src/pull-requests-gh.test.ts
pnpm --filter @harness/web exec vitest run src/ui/pull-requests/PullRequestImages.test.tsx src/ui/pull-requests/pull-request-image-source.test.ts

On 2026-09-15, the running development renderer on macOS loaded real private PNG and JPEG uploads that returned 404 anonymously. Authenticated cold reads took 920–932 ms; repeated server-cache reads took 0.08–0.24 ms. A five-image browser remount completed in 11 ms with zero additional image requests. These are spot measurements, not a network-latency guarantee.

The same browser check loaded a repository-relative SVG, decoded two distinct GIF animation frames, and confirmed that an SVG could neither execute a script nor request an external resource. Unit tests exercise 20 queued images with at most four concurrent CLI reads and 30 cached images across ten repeat views without additional RPC calls. The format verification screenshot excludes private upload contents. This renderer check does not replace the native Electron gate above.