Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a setting to show time to first window draw and frames per second in status bar #16422

Merged
merged 14 commits into from
Aug 18, 2024

Conversation

nathansobo
Copy link
Contributor

I want to showcase Zed's performance via videos, and this seemed like a good way to demonstrate it.

120.fps.Tab.Switch.mp4

Release Notes:

  • On macOS, you can now set assign performance.show_in_status_bar: true in your settings to show the time to the first window draw on startup and then current FPS of the containing window's renderer.

Now I need to build a UI to display it

- Implement mechanism to track time from app launch to first window draw
- Add TimeToFirstWindowDraw enum to represent initialization state
- Modify App, AppContext, and WindowContext to support measurement
- Log the duration once first window is drawn
- Initialize measurement in main.rs
- Create new `performance` crate with settings and status bar item
- Add `time_to_first_window_draw` accessor to AppContext
- Implement togglable performance metrics in status bar
- Add initialization of performance module in main
…t_window_draw

We'll need to add support for handling the on_complete callback when drawing windows
on Linux and Windows.
I used Claude to help me build an FPS counter that's efficient. Hopefully
it's not too complicated, but this is a hot code path.

This implementation uses a lock-free circular buffer to store frame timestamps
and calculate FPS. It maintains a rolling window of frame times for the last
second, allowing for smooth FPS updates without locking. Key features:

- Uses atomic operations for thread-safety without locks
- Maintains a fixed-size circular buffer of frame timestamps
- Automatically removes old timestamps (>1 second old)
- Calculates FPS based on frames in the last second
- Efficient O(1) time complexity for both increment and FPS calculation
@cla-bot cla-bot bot added the cla-signed The user has signed the Contributor License Agreement label Aug 18, 2024
nathansobo and others added 9 commits August 17, 2024 18:29
Release Notes:

- Fixed an issue where an extra newline was inserted after running a
`/file` command in the assistant.
Add language-specific subdirectory in example directory structure, since
that's the requisite structure - see `extensions/languages.md`

Release Notes:

- N/A
@nathansobo nathansobo merged commit 1175391 into main Aug 18, 2024
10 checks passed
@nathansobo nathansobo deleted the show-performance branch August 18, 2024 21:22
mrnugget added a commit that referenced this pull request Sep 6, 2024
This reverts the FPS counter added in 1175391 (#16422) because
in this issue someone bisected recent performance regressions down to
this commit:

- #16729

Another issue that's possibly related:

- #17305 (comment)

We're reverthing this in a PR to create a bundle that people can try
out.

Co-authored-by: Bennet <bennet@zed.dev>
@mrnugget mrnugget mentioned this pull request Sep 6, 2024
mrnugget added a commit that referenced this pull request Sep 6, 2024
**UPDATE**: Response so far seems to be that this fixes the performance
issues on Intel MacBooks. So we're going to go ahead and merge it.

This reverts the FPS counter added in 1175391 (#16422) because in this
issue someone bisected recent performance regressions down to this
commit:

- #16729

Another issue that's possibly related:

-
#17305 (comment)

We're reverting this in a PR to create a bundle that people can try out.

Assets:

- Universal Binary:
https://github.com/zed-industries/zed/actions/runs/10735702994/artifacts/1900460781
- x86/Intel:
https://github.com/zed-industries/zed/actions/runs/10735702994/artifacts/1900461236
- Apple Silicon:
https://github.com/zed-industries/zed/actions/runs/10735702994/artifacts/1900460978


Release Notes:

- Removed the recently-added FPS counter since the changes it made to
the Metal renderer on macOS could lead to performance regressions on
Intel MacBooks.

Co-authored-by: Bennet <bennet@zed.dev>
notpeter pushed a commit that referenced this pull request Sep 6, 2024
**UPDATE**: Response so far seems to be that this fixes the performance
issues on Intel MacBooks. So we're going to go ahead and merge it.

This reverts the FPS counter added in 1175391 (#16422) because in this
issue someone bisected recent performance regressions down to this
commit:

- #16729

Another issue that's possibly related:

-
#17305 (comment)

We're reverting this in a PR to create a bundle that people can try out.

Assets:

- Universal Binary:
https://github.com/zed-industries/zed/actions/runs/10735702994/artifacts/1900460781
- x86/Intel:
https://github.com/zed-industries/zed/actions/runs/10735702994/artifacts/1900461236
- Apple Silicon:
https://github.com/zed-industries/zed/actions/runs/10735702994/artifacts/1900460978


Release Notes:

- Removed the recently-added FPS counter since the changes it made to
the Metal renderer on macOS could lead to performance regressions on
Intel MacBooks.

Co-authored-by: Bennet <bennet@zed.dev>
notpeter pushed a commit that referenced this pull request Sep 6, 2024
**UPDATE**: Response so far seems to be that this fixes the performance
issues on Intel MacBooks. So we're going to go ahead and merge it.

This reverts the FPS counter added in 1175391 (#16422) because in this
issue someone bisected recent performance regressions down to this
commit:

- #16729

Another issue that's possibly related:

-
#17305 (comment)

We're reverting this in a PR to create a bundle that people can try out.

Assets:

- Universal Binary:
https://github.com/zed-industries/zed/actions/runs/10735702994/artifacts/1900460781
- x86/Intel:
https://github.com/zed-industries/zed/actions/runs/10735702994/artifacts/1900461236
- Apple Silicon:
https://github.com/zed-industries/zed/actions/runs/10735702994/artifacts/1900460978

Release Notes:

- Removed the recently-added FPS counter since the changes it made to
the Metal renderer on macOS could lead to performance regressions on
Intel MacBooks.

Co-authored-by: Bennet <bennet@zed.dev>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla-signed The user has signed the Contributor License Agreement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants