extension_host: Avoid creating a Tokio runtime (#45990)
While profiling Zed, I noticed around 12 `tokio-runtime-worker` threads.
Since `gpui_tokio` runs a Tokio runtime with only two worker threads,
this meant something else was spinning up a default Tokio runtime (My
machine has 10 cores).
After digging into it a bit, it looks like `wasmtime-wasi` needs a Tokio
runtime for some of its calls. That’s also why we run extension tasks on
`gpui-tokio` in the first place.
Reproduction case:
1. Run a clean Zed build.
2. Sample the process → only 2–3 Tokio threads.
3. Install a WASM extension (for example
https://github.com/zed-extensions/nix), which shouldn’t pull in anything
that creates its own runtime.
4. Sample the process again → 10+ Tokio worker threads show up.
```
marcocondrache@xawed ~/P/zed (main)> sample 34260 1 | grep -E "Thread_"
Sampling process 34260 for 1 second with 1 millisecond of run time between samples
Sampling completed, processing symbols...
Sample analysis of process 34260 written to file /tmp/zed_2026-01-03_112527_5pq7.sample.txt
744 Thread_3086626 DispatchQueue_1: com.apple.main-thread (serial)
744 Thread_3086629: RayonWorker0
....
744 Thread_3086651: MacWatcher
744 Thread_3086653: MacWatcher
744 Thread_3086661: com.apple.NSEventThread
744 Thread_3086680: tokio-runtime-worker
744 Thread_3086681: tokio-runtime-worker
...
744 Thread_3087087: tokio-runtime-worker
744 Thread_3087089: tokio-runtime-worker
744 Thread_3087090: tokio-runtime-worker
744 Thread_3087091: tokio-runtime-worker
744 Thread_3087092: tokio-runtime-worker
744 Thread_3087093: tokio-runtime-worker
744 Thread_3087094: tokio-runtime-worker
744 Thread_3087095: tokio-runtime-worker
744 Thread_3087096: tokio-runtime-worker
744 Thread_3087097: tokio-runtime-worker
...
```
Release Notes:
- Reduced number of threads when using extensions
---------
Signed-off-by: Marco Mihai Condrache <52580954+marcocondrache@users.noreply.github.com>
61b38890edMarco Mihai Condrache committed on 1/4/2026, 12:50:36 PM· committed by GitHubparent90d9df3