Home / Companies / Zed / Blog / April 2024

April 2024 Summaries

3 posts from Zed

Filter
Month: Year:
Post Summaries Back to Blog
In the blog post, the author explores the innovative data structure used by Zed, a high-performance code editor, focusing on its implementation of a "rope" through a SumTree. The rope, a type of binary tree, offers significant advantages over traditional strings for text representation, particularly in large files, due to its efficiency in handling text modifications without reallocating large continuous memory blocks. Zed's rope is not a classic binary-tree but a SumTree, which allows for concurrent access, snapshots, and asynchronous operations, aligning with Zed's goals for high performance and flexibility. The SumTree, a thread-safe, copy-on-write B+ tree, facilitates complex text operations such as converting between UTF8 and UTF16 rows/columns in O(log N) time. This structure enables efficient handling of text edits by updating tree pointers rather than moving large memory blocks, making it ideal for Zed’s requirements. Additionally, the SumTree is utilized throughout Zed, powering various components beyond the rope, demonstrating its integral role in Zed's architecture.
Apr 23, 2024 5,728 words in the original blog post.
About two months ago, a project to make the Zed code editor extensible was initiated, with a focus on supporting multiple programming languages through extensible language support. The first milestone has been achieved by enabling syntax-based analysis using Tree-sitter, which requires specific grammars and queries for each language, and the integration of WebAssembly (wasm) to safely distribute and run Tree-sitter parsers across platforms. This hybrid system combines native and wasm components to efficiently handle data exchanges during parsing without relying on a user's C compiler, minimizing crashes and enhancing performance. The introduction of a WasmStore type within the Tree-sitter API allows for the creation of language instances from wasm binaries, maintaining safety and performance, while minimizing memory leaks through a custom memory allocation strategy during parsing. Since the release of this feature, the Zed community has developed 67 language extensions, showcasing the system's flexibility and the support for syntax-aware features. Future posts will discuss further uses of wasm in Zed's extensibility, inviting users to explore and contribute to its growing capabilities.
Apr 18, 2024 1,748 words in the original blog post.
The article introduces a new series, "Zed Decoded," which explores the construction, technologies, and challenges of developing the Zed application, focusing particularly on its use of async Rust. The author collaborates with colleagues to delve into async Rust's implementation in Zed, discussing the application's high-performance capabilities. The article highlights the advantages of using macOS's Grand Central Dispatch (GCD) as the runtime for asynchronous code execution, diverging from traditional runtimes like tokio or smol. It explains the importance of maintaining responsiveness by distinguishing between foreground and background executors to prevent blocking the main thread, a critical aspect for UI applications. The author also touches on the collaborative effort in maintaining Zed's performance and responsiveness, providing examples from the codebase that illustrate how tasks are managed across different threads to ensure efficient operation. For further insights, the article references a companion video and future posts that will explore Zed's data structures and testing methodologies in more detail.
Apr 09, 2024 2,971 words in the original blog post.