Move the crash handler process spawn to a background thread - #58881
Merged
Conversation
This should speed up start up a bit
probably-neb
approved these changes
Jun 9, 2026
probably-neb
reviewed
Jun 9, 2026
This was referenced Jun 18, 2026
Closed
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Moves the crash handler subprocess spawn off the main thread to speed up startup, especially on Windows where process creation is slower.
Previously
crashes::initdid part of its work synchronously when it was called, includingspawn_crash_handler, which launches thezed --crash-handlerchild process (a synchronousCreateProcessWon Windows). Becauseinitis evaluated inline as the argument tobackground_executor().spawn(crashes::init(...))inmain.rs, that subprocess spawn ran on the main thread during startup rather than on the executor.This PR makes
connect_and_keepalivea fullyasync 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 processandconnected to crash handler process(e.g. #40621, #54856), all of which previously blocked the main thread.Related to #49442
Self-Review Checklist:
Release Notes: