development.md

 1# Developing Zed
 2
 3See the platform-specific instructions for building Zed from source:
 4
 5- [macOS](./development/macos.md)
 6- [Linux](./development/linux.md)
 7- [Windows](./development/windows.md)
 8
 9## Keychain access
10
11Zed stores secrets in the system keychain.
12
13However, when running a development build of Zed on macOS (and perhaps other
14platforms) trying to access the keychain results in a lot of keychain prompts
15that require entering your password over and over.
16
17On macOS this is caused by the development build not having a stable identity.
18Even if you choose the "Always Allow" option, the OS will still prompt you for
19your password again the next time something changes in the binary.
20
21This quickly becomes annoying and impedes development speed.
22
23That is why, by default, when running a development build of Zed an alternative
24credential provider is used in order to bypass the system keychain.
25
26> Note: This is **only** the case for development builds. For all non-development
27> release channels the system keychain is always used.
28
29If you need to test something out using the real system keychain in a
30development build, run Zed with the following environment variable set:
31
32```
33ZED_DEVELOPMENT_USE_KEYCHAIN=1
34```
35
36## Performance Measurements
37
38Zed includes a frame time measurement system that can be used to profile how long it takes to render each frame. This is particularly useful when comparing rendering performance between different versions or when optimizing frame rendering code.
39
40### Using ZED_MEASUREMENTS
41
42To enable performance measurements, set the `ZED_MEASUREMENTS` environment variable:
43
44```sh
45export ZED_MEASUREMENTS=1
46```
47
48When enabled, Zed will print frame rendering timing information to stderr, showing how long each frame takes to render.
49
50### Performance Comparison Workflow
51
52Here's a typical workflow for comparing frame rendering performance between different versions:
53
541. **Enable measurements:**
55
56   ```sh
57   export ZED_MEASUREMENTS=1
58   ```
59
602. **Test the first version:**
61
62   - Checkout the commit you want to measure
63   - Run Zed in release mode and use it for 5-10 seconds: `cargo run --release &> version-a`
64
653. **Test the second version:**
66
67   - Checkout another commit you want to compare
68   - Run Zed in release mode and use it for 5-10 seconds: `cargo run --release &> version-b`
69
704. **Generate comparison:**
71
72   ```sh
73   script/histogram version-a version-b
74   ```
75
76The `script/histogram` tool can accept as many measurement files as you like and will generate a histogram visualization comparing the frame rendering performance data between the provided versions.
77
78### Using `util_macros::perf`
79
80For benchmarking unit tests, annotate them with the `#[perf]` attribute from the `util_macros` crate. Then run `cargo
81perf-test -p $CRATE` to benchmark them. See the rustdoc documentation on `crates/util_macros` and `tooling/perf` for
82in-depth examples and explanations.
83
84## Contributor links
85
86- [CONTRIBUTING.md](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md)
87- [Debugging Crashes](./development/debugging-crashes.md)
88- [Code of Conduct](https://zed.dev/code-of-conduct)
89- [Zed Contributor License](https://zed.dev/cla)