Skip to content

Move the crash handler process spawn to a background thread - #58881

Merged
Anthony-Eid merged 3 commits into
mainfrom
move-crash-handler-spawn-to-background-thread
Jun 17, 2026
Merged

Move the crash handler process spawn to a background thread#58881
Anthony-Eid merged 3 commits into
mainfrom
move-crash-handler-spawn-to-background-thread

Conversation

@Anthony-Eid

@Anthony-Eid Anthony-Eid commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

Moves the crash handler subprocess spawn off the main thread to speed up startup, especially on Windows where process creation is slower.

Previously crashes::init did part of its work synchronously when it was called, including spawn_crash_handler, which launches the zed --crash-handler child process (a synchronous CreateProcessW on Windows). Because init is evaluated inline as the argument to background_executor().spawn(crashes::init(...)) in main.rs, that subprocess spawn ran on the main thread during startup rather than on the executor.

This PR makes connect_and_keepalive a fully async fn, so all of that work, including the subprocess spawn, now runs on the background executor instead of blocking the main thread.

I don't have a Windows machine to capture before/after numbers, but the crash handler spawn is clearly on the startup critical path. Logs in the Windows slow startup reports show it taking ~100–700ms between spawning crash handler process and connected to crash handler process (e.g. #40621, #54856), all of which previously blocked the main thread.

Related to #49442

Self-Review Checklist:

  • I've reviewed my own diff for quality, security, and reliability
  • Unsafe blocks (if any) have justifying comments
  • The content adheres to Zed's UI standards (UX/UI and icon guidelines)
  • Tests cover the new/changed behavior
  • Performance impact has been considered and is acceptable

Release Notes:

  • Improved startup performance

@cla-bot cla-bot Bot added the cla-signed The user has signed the Contributor License Agreement label Jun 9, 2026
@zed-community-bot zed-community-bot Bot added the staff Pull requests authored by a current member of Zed staff label Jun 9, 2026
Comment thread crates/crashes/src/crashes.rs Outdated
@Anthony-Eid
Anthony-Eid added this pull request to the merge queue Jun 17, 2026
Merged via the queue into main with commit 253606e Jun 17, 2026
40 checks passed
@Anthony-Eid
Anthony-Eid deleted the move-crash-handler-spawn-to-background-thread branch June 17, 2026 18:33
This was referenced Jun 18, 2026
jolutz pushed a commit to jolutz/zed that referenced this pull request Aug 8, 2026
…stries#58881)

Moves the crash handler subprocess spawn off the main thread to speed up
startup, especially on Windows where process creation is slower.

Previously `crashes::init` did part of its work synchronously when it
was *called*, including `spawn_crash_handler`, which launches the `zed
--crash-handler` child process (a synchronous `CreateProcessW` on
Windows). Because `init` is evaluated inline as the argument to
`background_executor().spawn(crashes::init(...))` in `main.rs`, that
subprocess spawn ran on the main thread during startup rather than on
the executor.

This PR makes `connect_and_keepalive` a fully `async fn`, so all of that
work, including the subprocess spawn, now runs on the background
executor instead of blocking the main thread.

I don't have a Windows machine to capture before/after numbers, but the
crash handler spawn is clearly on the startup critical path. Logs in the
Windows slow startup reports show it taking ~100–700ms between `spawning
crash handler process` and `connected to crash handler process` (e.g.
zed-industries#40621, zed-industries#54856), all of which previously blocked the main thread.

Related to zed-industries#49442

Self-Review Checklist:

- [x] I've reviewed my own diff for quality, security, and reliability
- [x] Unsafe blocks (if any) have justifying comments
- [x] The content adheres to Zed's UI standards
([UX/UI](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist)
and
[icon](https://github.com/zed-industries/zed/blob/main/crates/icons/README.md)
guidelines)
- [x] Tests cover the new/changed behavior
- [x] Performance impact has been considered and is acceptable

Release Notes:

- Improved startup performance
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla-signed The user has signed the Contributor License Agreement staff Pull requests authored by a current member of Zed staff

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants