Jakub Konka and Cole Miller
f4aa279898
util: Always use posix_spawn on macOS even with pre_exec hooks ( #49090 )
...
Here's some backstory:
* on macOS, @cole-miller and I noticed that since roughly Oct 2025, due
to some changes to latest macOS Tahoe, for any spawned child process we
needed to reset Mach exception ports
(https://github.com/zed-industries/zed/issues/36754 +
https://github.com/RemiKalbe/zed/commit/6e8f2d2ebe5a93753625a3026aeb996de8cb436b )
* the changes in that PR achieve that via `pre_exec` hook on
`std::process::Command` which then abandons `posix_spawn` syscall for
`fork` + `execve` dance on macOS (we tracked it down in Rust's std
implementation)
* as it turns out, `fork` + `execve` is pretty expensive on macOS
(apparently way more so than on other OSes like Linux) and `fork` takes
a process-wide lock on the allocator which is bad
* however, since we wanna reset exception ports on the child, the only
official way supported by Rust's std is to use `pre_exec` hook
* posix_spawn on macOS exposes this tho via a macOS specific extension
to that syscall `posix_spawnattr_setexceptionports_np` but there is no
way to use that via any standard interfaces in `std::process::Command`
* thus, it seemed like a good idea to instead create our own custom
Command wrapper that on non-macOS hosts is a zero-cost wrapper of
`smol::process::Command`, while on macOS we reimplement the minimum to
achieve `smol::process::Command` with `posix_spawn` under-the-hood
Notably, this changeset improves git-blame in very large repos
significantly.
Release Notes:
- Fixed performance spawning child processes on macOS by always forcing
`posix_spawn` no matter what.
---------
Co-authored-by: Cole Miller <cole@zed.dev >
2026-02-13 20:16:11 +01:00
..
2026-02-13 13:32:31 +00:00
2026-01-21 13:40:42 -03:00
2026-01-22 02:31:14 -05:00
2026-02-10 16:03:46 -03:00
2026-02-13 04:54:22 +00:00
2026-02-10 18:57:31 -05:00
2026-02-12 15:46:10 -05:00
2026-02-13 19:16:02 +01:00
2026-01-28 21:34:10 +00:00
2026-02-07 04:21:58 +00:00
2026-01-30 21:26:13 +00:00
2025-10-17 18:58:14 +00:00
2026-01-26 23:56:55 +00:00
2026-02-06 20:14:35 +01:00
2026-02-09 00:56:20 +01:00
2026-02-13 20:10:47 +01:00
2026-02-13 20:16:11 +01:00
2025-11-11 12:55:19 +00:00
2026-02-12 00:28:17 +00:00
2025-10-17 18:58:14 +00:00
2026-02-13 12:41:14 +01:00
2026-02-06 20:21:19 +00:00
2026-02-10 01:19:01 -05:00
2026-01-07 12:48:24 -08:00
2026-01-07 12:48:24 -08:00
2026-02-10 16:17:49 +01:00
2026-01-28 18:28:53 +00:00
2025-11-06 09:16:45 +00:00
2025-11-10 23:00:55 -07:00
2026-02-07 17:54:29 +00:00
2026-02-06 14:03:03 -05:00
2026-02-05 17:34:34 -05:00
2026-02-12 09:36:48 +02:00
2026-02-12 01:06:23 +00:00
2025-10-17 18:58:14 +00:00
2026-02-12 01:06:23 +00:00
2025-10-17 18:58:14 +00:00
2025-10-17 18:58:14 +00:00
2026-01-23 18:29:20 +01:00
2026-01-30 21:26:13 +00:00
2026-02-13 20:16:11 +01:00
2026-02-12 15:02:17 +00:00
2026-02-12 01:06:23 +00:00
2026-01-14 07:19:13 +00:00
2026-01-07 12:48:24 -08:00
2026-01-28 16:00:52 +00:00
2026-02-13 20:16:11 +01:00
2026-02-12 16:26:13 +00:00
2026-01-14 07:19:13 +00:00
2026-02-10 23:29:51 +00:00
2026-02-12 01:06:23 +00:00
2025-12-18 12:47:34 +00:00
2025-10-17 18:58:14 +00:00
2026-02-13 20:16:11 +01:00
2026-02-12 01:06:23 +00:00
2026-02-04 17:37:13 +00:00
2026-02-13 13:26:03 +00:00
2026-02-12 15:24:24 -05:00
2026-02-12 15:24:24 -05:00
2026-02-04 17:54:11 -05:00
2026-02-13 00:15:59 +00:00
2026-02-13 11:57:43 -06:00
2026-02-12 00:28:17 +00:00
2026-02-13 20:16:11 +01:00
2025-12-18 17:26:20 +01:00
2025-10-17 18:58:14 +00:00
2026-02-13 20:16:11 +01:00
2026-02-05 12:13:02 +00:00
2026-02-07 17:54:29 +00:00
2026-02-13 20:16:11 +01:00
2026-02-12 00:28:17 +00:00
2026-02-13 14:51:49 +00:00
2025-10-17 18:58:14 +00:00
2026-02-13 16:05:40 +00:00
2025-10-17 18:58:14 +00:00
2026-02-13 20:16:11 +01:00
2025-10-20 10:30:06 +00:00
2025-12-08 19:50:20 +01:00
2026-02-13 20:16:11 +01:00
2026-02-12 23:57:19 +00:00
2026-01-31 21:56:34 +00:00
2026-02-13 10:39:30 -03:00
2026-02-12 01:06:23 +00:00
2025-12-17 20:12:40 -06:00
2026-02-13 20:16:11 +01:00
2026-01-27 15:37:22 -03:00
2026-01-07 12:48:24 -08:00
2025-10-17 18:58:14 +00:00
2025-12-09 09:29:40 -08:00
2025-10-17 18:58:14 +00:00
2026-02-13 10:39:30 -03:00
2026-02-05 09:31:11 +00:00
2026-02-13 20:16:11 +01:00
2026-02-12 00:28:17 +00:00
2026-02-12 01:06:23 +00:00
2026-02-12 09:58:38 -05:00
2026-02-12 01:06:23 +00:00
2026-02-13 12:06:34 +01:00
2026-02-04 23:03:15 +01:00
2026-02-07 04:21:58 +00:00
2026-02-13 19:16:02 +01:00
2025-10-17 18:58:14 +00:00
2026-01-23 18:29:20 +01:00
2026-02-12 17:55:36 +00:00
2026-02-13 20:16:11 +01:00
2025-10-22 19:52:38 +00:00
2026-02-03 15:51:40 -05:00
2026-02-12 14:27:55 +01:00
2025-10-17 18:58:14 +00:00
2026-02-13 20:16:11 +01:00
2026-02-02 16:37:58 +00:00
2026-02-13 15:25:40 +05:30
2025-10-17 18:58:14 +00:00
2025-12-30 07:49:01 -03:00
2026-02-10 18:57:31 -05:00
2026-02-12 01:06:23 +00:00
2026-02-13 12:03:05 +00:00
2026-02-10 20:20:57 +00:00
2026-01-06 08:14:34 +00:00
2025-10-17 18:58:14 +00:00
2026-02-13 20:16:11 +01:00
2026-01-07 12:48:24 -08:00
2026-02-12 16:58:24 +00:00
2026-02-12 01:06:23 +00:00
2026-02-13 04:54:22 +00:00
2026-02-12 01:06:23 +00:00
2026-02-12 14:02:16 +00:00
2026-02-12 09:36:48 +02:00
2026-02-12 09:36:48 +02:00
2026-02-02 13:30:07 +01:00
2026-02-06 15:34:36 +00:00
2026-01-23 18:29:20 +01:00
2026-02-12 01:06:23 +00:00
2026-02-07 00:36:37 +00:00
2026-02-13 20:16:11 +01:00
2026-01-20 15:41:31 -05:00
2026-02-13 16:05:40 +00:00
2026-02-12 01:06:23 +00:00
2026-01-30 21:26:13 +00:00
2026-02-11 21:30:03 +02:00
2026-02-13 20:16:11 +01:00
2025-12-15 13:30:13 +00:00
2025-11-27 13:46:43 +00:00
2026-02-13 20:16:11 +01:00
2026-02-02 13:30:07 +01:00
2026-02-13 20:16:11 +01:00
2026-02-13 20:16:11 +01:00
2026-02-04 01:33:12 +00:00
2025-11-03 19:25:15 +00:00
2026-02-11 14:21:13 +01:00
2026-02-11 21:30:03 +02:00
2026-02-12 01:06:23 +00:00
2026-01-15 18:39:06 +00:00
2025-12-16 10:48:14 -05:00
2026-02-13 17:54:17 +02:00
2026-02-12 01:06:23 +00:00
2026-02-13 11:57:43 -06:00
2026-02-13 11:57:43 -06:00
2025-10-27 10:13:26 -04:00
2025-11-21 08:28:17 -07:00
2026-02-12 01:06:23 +00:00
2026-02-13 20:10:47 +01:00
2026-02-09 08:56:21 -05:00
2026-02-12 23:57:45 +00:00
2025-10-17 18:58:14 +00:00
2026-01-26 13:49:26 +00:00
2026-02-12 00:28:17 +00:00
2025-10-17 18:58:14 +00:00
2025-10-17 18:58:14 +00:00
2025-10-17 18:58:14 +00:00
2026-01-29 16:33:38 -03:00
2025-11-03 19:25:15 +00:00
2026-02-05 20:10:02 +00:00
2026-02-13 20:16:11 +01:00
2026-01-04 23:28:18 +00:00
2026-01-28 00:19:13 -03:00
2025-11-24 13:34:04 +01:00
2026-02-12 12:33:51 +00:00
2026-02-12 16:30:47 +00:00
2026-02-12 01:06:23 +00:00
2025-11-07 11:36:05 +00:00
2026-01-28 16:36:44 -08:00
2026-02-13 10:19:43 -06:00
2026-02-13 09:46:18 -06:00
2026-02-08 20:10:52 -05:00
2026-02-04 17:37:13 +00:00
2025-10-17 18:58:14 +00:00
2026-01-15 18:10:21 +00:00
2025-12-01 20:52:57 -07:00
2026-01-28 17:05:34 +01:00
2026-02-12 09:54:33 -03:00
2026-02-02 16:56:25 +00:00
2026-02-13 11:24:16 -03:00
2026-02-02 13:30:07 +01:00
2025-10-17 18:58:14 +00:00
2025-10-17 18:58:14 +00:00
2026-02-13 20:16:11 +01:00
2025-10-17 18:58:14 +00:00
2026-01-25 21:35:32 +01:00
2026-02-12 12:33:51 +00:00
2025-11-07 22:27:14 +00:00
2025-10-17 18:58:14 +00:00
2025-10-17 18:58:14 +00:00
2026-01-23 20:50:50 +00:00
2025-12-17 11:53:48 -07:00
2026-02-13 14:17:58 +00:00
2026-02-12 04:50:54 +00:00
2026-01-29 15:31:13 +00:00
2025-12-08 16:38:34 +01:00
2026-02-13 11:57:43 -06:00
2026-02-12 15:46:10 -05:00
2025-12-13 11:06:30 -05:00
2026-02-13 13:47:28 +02:00
2026-02-13 02:55:42 -05:00
2025-11-07 22:27:14 +00:00
2026-02-11 11:24:04 +00:00
2025-12-05 17:23:06 +00:00