zed/crates/crashes
Anthony Eid 253606e8e0
Move the crash handler process spawn to a background thread (#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.
#40621, #54856), all of which previously blocked the main thread.

Related to #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
2026-06-17 18:29:21 +00:00
..
src Move the crash handler process spawn to a background thread (#58881) 2026-06-17 18:29:21 +00:00
Cargo.toml Cleanup crashes crate (#54927) 2026-05-04 06:30:47 +00:00
LICENSE-GPL Add minidump crash reporting (#35263) 2025-08-04 18:19:42 -07:00