docs/src/performance.md
How to use our internal tools to profile and keep Zed fast.
See what the CPU spends the most time on. Strongly recommend you use samply. It opens an interactive profile in the browser (specifically a local instance of firefox_profiler).
See samply's README on how to install and run.
The profile.json does not contain any symbols. Firefox profiler can add the local symbols to the profile for for. To do that hit the upload local profile button in the top right corner.
See how long each annotated function call took and its arguments (if configured).
Annotate any function you need appear in the profile with instrument. For more details see tracing-instrument:
#[instrument(skip_all)]
fn should_appear_in_profile(kitty: Cat) {
sleep(QUITE_LONG)
}
Then either compile Zed with ZTRACING=1 cargo r --features tracy --release. The release build is optional but highly recommended as like every program Zeds performance characteristics change dramatically with optimizations. You do not want to chase slowdowns that do not exist in release.
Download the profiler: linux x86_64 macos aarch64
cd profiler && mkdir build && cd buildcmake -G Ninja -DCMAKE_BUILD_TYPE=Release ..ninjaOpen the profiler (tracy-profiler), you should see zed in the list of Discovered clients click it.
To find functions that take a long time follow this image:
Get a profile of the zed foreground executor and background executors. Check if anything is blocking the foreground too long or taking too much (clock) time in the background.
The profiler always runs in the background. You can save a trace from its UI or look at the results live.
Download the importer linux x86_64 mac aarch64
cd import && mkdir build && cd buildcmake -G Ninja -DCMAKE_BUILD_TYPE=Release ..ninja./tracy-import-miniprofiler /path/to/trace.miniprof.json /path/to/output.tracyzed open performance profiler./tracy-import-miniprofiler <path to performance_profile.miniprof.json> output.tracylet _timer = zlog::time!("my_function_name").warn_if_gt(std::time::Duration::from_millis(100));