Skip to content

perf(desktop): windows updates skip six powershell checks, cutting install time from 10s to 3s - #231

Merged
AadiJo merged 1 commit into
mainfrom
windows-upgrade-faster
Nov 9, 2026
Merged

AadiJo merged 1 commit into
mainfrom
windows-upgrade-faster

Conversation

@AadiJo

@AadiJo AadiJo commented Nov 9, 2026 •

Copy link
Copy Markdown
Member

Restarting to install a Windows update took too long. Timing real upgrades between two nightlies showed that more than half of the ~10s NSIS step went to electron-builder's "is the app running" check. That check starts PowerShell three times (an availability probe, an execution-policy probe, then a Win32_Process path scan) even when nothing is running. The previous version's uninstaller then runs the same check again.

apps/desktop/resources/installer.nsh replaces it via nsis.include. It asks whether a running process still holds the main exe or the resource monitor. Windows refuses write access to a running image, and backend children run as the main exe, so one lock covers them. During an update it waits up to 5s for the quitting app to exit. If a lock is still there after that, it hands over to the stock check, which still finds, kills, and prompts.

Upgrade on a Windows 11 i9 / NVMe machine (median of 3) NSIS time
Stock installer over stock install (today) 9.9s
New installer over stock install (first update after this ships) 7.4s
New installer over new install (every update after) 3.1s

The first release only gets the installer half. The other ~3s goes away once the old version's uninstaller also has the new check.

scripts/windows-upgrade-timing.ps1 is the harness behind these numbers. It installs one build, upgrades with another the way quitAndInstall does (--updated /S), splits the NSIS run into phases, then launches the result against a throwaway CADSENSE_HOME. Each run writes report.md, report.json, and a per-run timeline.csv. All channels share one app id, so it replaces the installed Cadsense for the current user.

Verification

Proved by building real installers with and without the include on Windows using the CI versions of electron-builder (26.15.6) and NSIS (3.0.4.1), then timing upgrades with the harness and forcing the fallback path.

  • Both variants compile with NSIS warnings as errors.
  • Fallback: with the main exe held for 2s (app still quitting), the installer waits, makes no PowerShell calls, and installs. With the main exe held indefinitely, it polls for 5s, then runs the stock check, and the install succeeds.
  • Lock probe: the main exe running as ELECTRON_RUN_AS_NODE (the backend's shape) reads as locked, an idle exe as free, a missing file is not created, and the exe's timestamp is unchanged.
  • scripts typecheck, lint, and format are clean. build-desktop-artifact.test.ts passes.

Limitations

  • The in-app trigger was simulated (installer started with --updated /S while a process held the exe), not clicked through a downloaded update.
  • electron-builder's stock scan misses the case where exactly one process runs from the install dir. A single CIM object has no .Count in Windows PowerShell 5.1. The fallback inherits that blind spot. The install still succeeds because the uninstaller can rename a running exe.

Reviewed with sol-loop: 1 round with gpt-6.1-sol. Sol verdict: approved


Autofix with [code]smith
Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.

@vercel

vercel Bot commented Nov 9, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated
cadsense Skipped Skipped Nov 9, 2026 1:56am UTC

@AadiJo
AadiJo merged commit 9692a0e into main Nov 9, 2026
8 checks passed
@AadiJo
AadiJo deleted the windows-upgrade-faster branch November 26, 2026 19:52

This branch was previously deployed

1 inactive deployment
Preview — ea98e130 Deployed Nov 9, 2026 by vercel[bot]
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