From 94e90d94c8c33d6f64396dc872e141f8380b8dab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yara=20=F0=9F=8F=B3=EF=B8=8F=E2=80=8D=E2=9A=A7=EF=B8=8F?= Date: Mon, 30 Mar 2026 14:33:42 +0200 Subject: [PATCH] docs: Add detailed tracy workflow to `performance.md` (#52574) 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 is consistent with the [UI/UX checklist](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist) - [x] Tests cover the new/changed behavior - [x] Performance impact has been considered and is acceptable Release Notes: - Improved performance documentation in "Developing Zed" --------- Co-authored-by: Zed Zippy <234243425+zed-zippy[bot]@users.noreply.github.com> --- docs/src/performance.md | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/docs/src/performance.md b/docs/src/performance.md index e52ea9c684de0e2b9d39efe2741dfe0728bc7641..b8f76179e16fcf1f1b886a5c3ef00bcc85aa9ed4 100644 --- a/docs/src/performance.md +++ b/docs/src/performance.md @@ -55,9 +55,32 @@ Open the profiler (tracy-profiler), you should see zed in the list of `Discovere image -To find functions that take a long time follow this image: +Tracy is an incredibly powerful profiler which can do a lot however it's UI is not that friendly. This is not the place for an in depth guide to Tracy, I do however want to highlight one particular workflow that is helpful when figuring out why a piece of code is _sometimes_ slow. -image +Here are the steps: + +1. Click the flamechart button at the top. +2. Click on a function that takes a lot of time. +3. Expand the list of function calls by clicking on main thread. +4. Filter that list to the slower calls then click on one of the slow calls in the list +5. Click zoom to zone to go to that specific function call in the timeline +6. Scroll to zoom in and see more detail about the callers +7. Click on a caller to to get statistics on _it_. + +While normally the blue bars in the Tracy timeline correspond to function calls they can time any part of a codebase. In the example below we have added an extra span "for block in edits" and added metadata to it: the block_height. You can do that like this: + +```rust +let span = ztracing::debug_span!("for block in edits", block_height = block.height()); +let _enter = span.enter(); // span guard, when this is dropped the span ends (and its duration is recorded) +``` + +Click flamechart +Click snapshot +Click main thread +Select the tail calls in the histogram to filter down the list of calls then click on one call +Click zoom to zone +Scroll to zoom in +Click on any of the zones to get statistics # Task/Async profiling