---
title: "Async Rust"
description: "Zed's GPUI framework runs async Rust without tokio or smol: it uses async_task for tasks and thin wrappers around macOS Grand Central Dispatch as the executor, dispatching Runnables via dispatch_async_f onto the main queue or a high-priority global queue through a trampoline function."
url: "https://swe.quest/articles/async-rust-c6376cf98e387782"
canonical: "https://zed.dev/blog/zed-decoded-async-rust"
source: "Zed"
published: "2024-04-09"
difficulty: "medium"
kind: "Deep dive"
reading_minutes: 11
tags: ["rust","concurrency","runtimes","developer-tools","performance"]
---

# Async Rust

A post on [Zed](https://swe.quest/sources/zed.md), published 2024-04-09, 11 min read, Deep dive. Original: [https://zed.dev/blog/zed-decoded-async-rust](https://zed.dev/blog/zed-decoded-async-rust)

## Summary

Zed's GPUI framework runs async Rust without tokio or smol: it uses async\_task for tasks and thin wrappers around macOS Grand Central Dispatch as the executor, dispatching Runnables via dispatch\_async\_f onto the main queue or a high-priority global queue through a trampoline function. GPUI separates a ForegroundExecutor (main thread, which handles rendering and input and must never block) from a BackgroundExecutor (GCD global queue). Code walkthroughs from the editor, terminal search and project-wide search show the pattern of keeping quick work on the main thread and pushing lock acquisition, file scanning and searching to background tasks so frames hit the 8ms budget at 120 FPS.

Written by swe.quest, not by the author.

**Difficulty:** Medium: assumes a working developer; shows how it is built or done

## Topics

- [Rust](https://swe.quest/tags/rust.md) (Languages)
- [Concurrency](https://swe.quest/tags/concurrency.md) (Compilers & runtimes)
- [Runtimes & VMs](https://swe.quest/tags/runtimes.md) (Compilers & runtimes)
- [Developer tools](https://swe.quest/tags/developer-tools.md) (Engineering practices)
- [Performance engineering](https://swe.quest/tags/performance.md) (Reliability & operations)

## Prerequisites

- async Rust futures ([easy posts on Concurrency](https://swe.quest/tags/concurrency.md?difficulty=easy))
- Rust Arc and Mutex ([easy posts on Rust](https://swe.quest/tags/rust.md?difficulty=easy))
- UI main thread model

## Keywords

Zed, GPUI, Grand Central Dispatch, async\_task, smol, macOS

## Related posts

- [Zed Weekly: #29](https://swe.quest/articles/zed-weekly-29-41f27bba860d0170.md): Zed · 2023-12-15 · Medium · 6 min read · Rust, Memory management, Performance engineering, Frontend, Developer tools
  Zed's port to GPUI 2 is nearing daily usability, and the team is focused on frame-rendering performance measured by holding tab-switch at 60Hz key repeat.
- [Zed Weekly: #22](https://swe.quest/articles/zed-weekly-22-1c922abde503e316.md): Zed · 2023-10-06 · Easy · 7 min read · Developer tools, Rust, Real-time systems, Product engineering
  Zed team members report weekly progress: GPUI is being rewritten with a ported Metal renderer that uses plane-split for primitive draw ordering, multi-threaded entity access, and a MainThread\<T: Context\> wrapper so native UI APIs are only called from the main thread.
- [Leveraging Rust and the GPU to render user interfaces at 120 FPS](https://swe.quest/articles/leveraging-rust-and-the-gpu-to-render-user-interfaces-at-120-fps-8175e9071db5a167.md): Zed · 2023-03-07 · Hard · 16 min read · Performance engineering, Rust, Frontend, Hardware, Developer tools
  Zed's GPUI framework hits 120 FPS by rendering the editor UI like a video game: rather than a general-purpose 2D vector renderer (Pathfinder proved too slow), it uses dedicated GPU shaders for a small set of primitives such as rectangles, shadows, text, icons and images, all described as data on the CPU and drawn with instanced rendering.
- [Optimizing the Metal pipeline to maintain 120 FPS in GPUI](https://swe.quest/articles/optimizing-the-metal-pipeline-to-maintain-120-fps-in-gpui-951f2f761e0fc50d.md): Zed · 2024-02-07 · Medium · 9 min read · Performance engineering, Frontend, Rust, Hardware, Debugging
  Zed's GPUI renderer dropped frames on Macs running in direct (non-composited) mode because \`MetalRenderer::draw\` blocked the main thread with \`wait\_until\_completed\`.
- [We Have to Start Over: From Atom to Zed](https://swe.quest/articles/we-have-to-start-over-from-atom-to-zed-8db3be76f03d8a79.md): Zed · 2024-02-12 · Easy · 25 min read · Rust, Developer tools, Performance engineering, Data structures
  Zed's co-founders explain why they abandoned Atom's Electron/JavaScript stack and rebuilt a code editor in Rust: JavaScript's pointer-chasing arrays, uncontrollable GC pauses, and the costly JS/C++ boundary for multithreading made performance work feel like fighting the platform.

Browse: [Latest posts](https://swe.quest/index.md) · [Topics](https://swe.quest/tags.md) · [Sources](https://swe.quest/sources.md) · [Topic map](https://swe.quest/map.md) · [Site guide (llms.txt)](https://swe.quest/llms.txt)
