Add performance doc (#43265)

David Kleingeld created

Release Notes:

- N/A

Change summary

docs/src/SUMMARY.md     |  1 +
docs/src/performance.md | 32 ++++++++++++++++++++++++++++++++
2 files changed, 33 insertions(+)

Detailed changes

docs/src/SUMMARY.md 🔗

@@ -167,6 +167,7 @@
   - [FreeBSD](./development/freebsd.md)
   - [Local Collaboration](./development/local-collaboration.md)
   - [Using Debuggers](./development/debuggers.md)
+  - [Performance](./performance.md)
   - [Glossary](./development/glossary.md)
 - [Release Notes](./development/release-notes.md)
 - [Debugging Crashes](./development/debugging-crashes.md)

docs/src/performance.md 🔗

@@ -0,0 +1,32 @@
+How to use our internal tools to profile and keep Zed fast.
+
+# Tracy
+
+Get a profile of the zed foreground executor
+
+The profiler always runs in the background. You can save a trace from its UI or look at the results live.
+
+## Setup/Building the importer:
+
+- Clone the repo at git@github.com:zed-industries/tracy.git on v0.12.2 branch
+- `cd profiler && mkdir build && cd build`
+- Run cmake to generate build files: `cmake -G Ninja -DCMAKE_BUILD_TYPE=Release ..`
+- Build the importer: `ninja`
+- Run the impoter on the trace file: `./tracy-import-miniprofiler /path/to/trace.miniprof /path/to/output.tracy`
+- Open the trace in tracy:
+  - If you're on windows download the v0.12.2 version from the releases on the upstream repo
+  - If you're on other platforms open it on the website: https://tracy.nereid.pl/ (the version might mismatch so your luck might vary, we need to host our own ideally..)
+
+## To Save a Trace:
+
+- Run the action: `zed open performance profiler`
+- Hit the save button. This opens a save dialog or if that fails to open the trace gets saved in your working directory.
+- Convert the profile so it can be imported in tracy using the importer: `./tracy-import-miniprofiler <path to performance_profile.miniprof> output.tracy`
+- Go to <https://tracy.nereid.pl/> hit the 'power button' in the top left and then open saved trace.
+- Now zoom in to see the tasks and how long they took
+
+# Warn if function is slow
+
+```rust
+let _timer = zlog::time!("my_function_name").warn_if_gt(std::time::Duration::from_millis(100));
+```