-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
perf(tui): bring async to tui (#9132)
### Description This PR makes the driving the TUI async, the actual operation on the state is still completely sync. The primary driver behind this PR is it allows us to make use of [`crossterm::event::EventStream`](https://docs.rs/crossterm/latest/crossterm/event/struct.EventStream.html) which seems to be far more performant than polling for user input. The first commit of the PR just changes types from `std::sync::mpsc` to `tokio::sync::mpsc` (and make use of `tokio::sync::oneshot` for our callbacks instead of a channel of size 1). The second commit removes our usage of `crossterm::event::poll` in favor of a dedicated task that reads and forwards events from `crossterm::event::EventStream`. The final commit moves the production of ticks to it's own task to avoid the need for timing out our reads. ### Testing Instructions Notice large reduction in CPU usage from `turbo` when tasks are not producing output and the TUI is just waiting for user input. Before <img width="331" alt="Screenshot 2024-09-10 at 2 57 45 PM" src="https://github.com/user-attachments/assets/ad85fa7a-7b55-4459-a6c0-c0a7931e8738"> After <img width="393" alt="Screenshot 2024-09-10 at 2 56 17 PM" src="https://github.com/user-attachments/assets/9b6793b2-bca6-4baa-ab4d-3182e561212e">
- Loading branch information
1 parent
42696fe
commit 791a033
Showing
12 changed files
with
127 additions
and
85 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.