Skip to content
Source
Sign inSign up
pingdotgg/t3code

perf(windows): optimize Windows on ARM performance and native update support #18508

Closedmweinbach(GitHub profile, opens in a new tab)wants to merge 10 commits intomain fromrefs/pull/18508/headopened View on GitHub

Problem

On Windows and Windows on ARM (win32-arm64), T3 Code suffers from severe responsiveness bottlenecks, high background CPU/IPC overhead, slow startup, and update/provider issues that push x64 builds onto ARM hosts or fail on ARM64 installations:

  1. Port discovery WMI polling: PortScanner spawns powershell.exe Get-NetTCPConnection + Get-Process every 3 seconds even when no terminals are active, taking up to 22.5s and timing out at 5s on every poll.
  2. Main-thread FFI overhead in @ff-labs/fff-node: Workspace file searches perform 7 separate FFI calls plus manual char-by-char pointer reads per result (175,000+ FFI calls for 25k files), stalling the server event loop for >4s and causing WebSocket ping disconnects.
  3. Synchronous SQLite WAL commits: Sqlite.ts enables journal_mode = WAL with the default synchronous = FULL, invoking FlushFileBuffers() on every EventSink.write transaction on Windows.
  4. Duplicate startup shell environment probes & Android SDK PATH scans: The server re-runs synchronous PowerShell login probes even when the desktop parent already prepared the environment, mergeWindowsEnv leaves colliding Path/PATH keys, and LocalDeviceHost scans every PATH directory before checking %LOCALAPPDATA%\Android\Sdk.
  5. Renderer IPC storm during streaming: SnapShotCoordinator recreates drain whenever activeThreadRef updates, firing desktop:list-pending-snap-shots on every streaming turn update.
  6. Full-system PEB process enumeration in t3-resource-monitor: On Windows, sysinfo::ProcessRefreshKind::everything() reads PEB command lines, memory, and disk I/O for every process on the machine every 2 seconds instead of only tracked PIDs.
  7. Windows terminal teardown hangs & console window flashes: node-pty's conpty_console_list_agent only listens for message and hangs for 5s if the helper exits early, Manager.runKillEscalation sleeps for the full grace period after exit, and detached helper spawns flash console windows.
  8. Windows on ARM updates & provider installs: NsisUpdater checks process.arch ("x64" under Prism emulation) or falls back to the first manifest entry, keeping emulated installs on x64 or pushing x64 updates to ARM hosts; DesktopEnvironment ignores runningUnderArm64Translation on win32; .github/workflows/release.yml falls back to an x64-only latest.yml/nightly.yml if the arm64 manifest is missing; ACP Registry providers lack a windows-aarch64 -> windows-x86_64 Prism fallback; and CodexInstallation can hit GNU tar path parsing or transient Windows file-lock rename failures after validation.

Change

  • PortScanner: Short-circuit in 0ms when targetPids is empty and replace Get-NetTCPConnection PowerShell WMI polling with concurrent netstat.exe -ano -p tcp / tcpv6 calls (~50ms).
  • @ff-labs/fff-node patch: Marshal string fields via DataType.String in a single struct return and skip per-item get_score FFI calls when count > 200, cutting 25k-item queries from 4.16s to ~1.12s.
  • SQLite WAL: Set PRAGMA synchronous = NORMAL; alongside PRAGMA journal_mode = WAL;.
  • Startup & device discovery: Respect shellEnvironmentPrepared: true on win32, run shellEnvironment.installIntoProcess concurrently with electronApp.whenReady, deduplicate Path/PATH keys in mergeWindowsEnv, check standard Android SDK locations before scanning PATH, and skip no-op DeviceService.refreshHosts runs.
  • SnapShotCoordinator: Stabilize drain with a ref so streaming thread state updates do not trigger listPendingSnapShots IPC calls.
  • t3-resource-monitor: Enable two-stage process refresh on Windows (ProcessRefreshKind::nothing().with_cpu() across the system, then everything() only for tracked PIDs) and resolve target-triple binary paths in ResourceMonitorBinary.ts.
  • Terminals & process spawning: Handle exit/error on conpty_console_list_agent in node-pty, race process.onExit against processKillGraceMs in Manager.ts, remove the redundant 1s Windows teardown sleep in OpenCodeRuntime.ts, and pass windowsHide: true on detached spawns.
  • Windows on ARM updates & providers:
    • Preserve runningUnderArm64Translation and hostArch: "arm64" on win32 in DesktopEnvironment.ts so DesktopUpdates disables differential downloads when switching from x64 to arm64.
    • Filter updateInfo.files to hostArch in DesktopUpdates.ts (ignoring manifests that carry no package for hostArch) and add NsisUpdater.filterFilesForArch in patches/electron-updater@6.8.9.patch so ARM64 Windows hosts always select arm64.exe.
    • Order arm64 first when merging Windows update manifests in .github/workflows/release.yml and fail if the arm64 manifest is missing instead of publishing an x64-only manifest.
    • Add the Windows arm64.exe download link to /download and update the architecture warning copy for Windows on ARM.
    • Fall back from windows-aarch64 to windows-x86_64 in AcpRegistrySupport.ts, and use System32\tar.exe plus fs.rename retries and stale .install-* cleanup in CodexInstallation.ts.

Model: Claude 5.5 Opus

    1. chatgpt-codex-connector[bot](GitHub profile, opens in a new tab)commented

      Codex Review Summary

      This comment shows the latest Codex review activity on this pull request.

      ReviewStatusCommitReview trigger
      📝 Code Review✅ Completed 2026-10-12T05:05:10.353476Z093e451PR opened
      ℹ️ About Codex in GitHub

      Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

      • Open a pull request for review
      • Mark a draft as ready
      • Comment "@codex review" or "@codex security review".

      Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

    2. github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:unvouched

    3. Note

      This comment is posted by Julius' dot

      Closing because this combines independent fixes: replacing PortScanner polling, reducing file-search FFI calls, and selecting ARM64 update packages each solves a separate problem without needing the others. Please split these into focused PRs under the one-problem rule, with reproduction steps and verification for each. Discuss the separate SQLite synchronous-mode default change with maintainers before including it.

    4. Approvability

      Verdict: Not approved

      Macroscope's review found this PR not approvable — This PR introduces broad Windows-on-ARM runtime, updater, provider, terminal, monitoring, release, and dependency behavior changes across the product. It also changes the SQLite persistence default to synchronous = NORMAL, making the change unsuitable for automatic approval.

      You can add or adjust custom eligibility rules. [Learn more](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).
    5. juliusmarminge closed this

    6. 💡 Codex Review

      Here are some automated review suggestions for this pull request.

      Reviewed commit: 093e451ce6

      ℹ️ About Codex in GitHub

      Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

      • Open a pull request for review
      • Mark a draft as ready
      • Comment "@codex review".

      If Codex has suggestions, it will comment; otherwise it will react with 👍.

      Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

      @@ -9,4 +9,9 @@
      99 // oxlint-disable-next-line t3code/no-global-process-runtime -- Standalone repair script has no Effect runtime.
      1010 const hostPlatform = NodeOS.platform();
      1111 // oxlint-disable-next-line t3code/no-global-process-runtime -- Standalone repair script has no Effect runtime.
      12-const hostArch = NodeOS.arch();
      12+const rawHostArch = NodeOS.arch();
      13+const hostArch =
      14+ hostPlatform === "win32" &&
      15+ rawHostArch === "x64" &&
      16+ process.env.PROCESSOR_ARCHITEW6432?.toUpperCase() === "ARM64"
      17+ ? "arm64"

      P2 Badge Keep Electron aligned with the installed native modules

      On an ARM64 Windows machine running an x64 Node toolchain, this changes only the architecture of a repaired Electron runtime: pnpm still treats current as x64 (pnpm-workspace.yaml:334-337), and native modules such as node-pty and ffi-rs are therefore installed or built for x64. If ensureElectronRuntime() repairs a missing or invalid runtime, it now downloads arm64 Electron, which is also used as the backend Node executable by DesktopBackendConfiguration.ts; loading those x64 addons from that process then fails with an architecture mismatch. Either keep the repair on rawHostArch or provision/rebuild every native dependency for arm64 as part of the switch.

      Useful? React with 👍 / 👎.

      @@ -216,4 +216,18 @@
      216216 const pendingAnimationStartsRef = useRef(new Set<string>());
      217217
      218218 const currentTarget = routeThreadRef ?? routeDraftId;
      219- if (currentTarget) lastTargetRef.current = currentTarget;
      219+ const latestContextRef = useRef({
      220+ activeDraftThread,
      221+ activeThread,
      222+ animateCaptures,
      223+ captureSound,
      224+ defaultProjectRef,
      225+ handleNewThread,
      226+ routeThreadRef,
      227+ });
      228+
      229+ useEffect(() => {
      230+ if (currentTarget) {
      231+ lastTargetRef.current = currentTarget;
      232+ }
      233+ latestContextRef.current = {

      P2 Badge Update snapshot routing before passive effects

      When navigation commits, the existing bridge listener remains subscribed because its dependencies are now stable, but both lastTargetRef and latestContextRef retain the previous route until this passive effect runs. If a requested or ready desktop IPC event arrives after the new thread commits but before passive effects flush, the capture can be pinned or delivered to the thread the user just left. Update these refs with a layout-synchronous or event-ref primitive while preserving the stable callback identities.

      Useful? React with 👍 / 👎.

Sign in to join this conversation.