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

perf(tui): bring async to tui #9132

Merged
merged 3 commits into from
Oct 17, 2024
Merged

Conversation

chris-olszewski
Copy link
Member

@chris-olszewski chris-olszewski commented Sep 10, 2024

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 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
Screenshot 2024-09-10 at 2 57 45 PM

After
Screenshot 2024-09-10 at 2 56 17 PM

Copy link

vercel bot commented Sep 10, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
examples-nonmonorepo ✅ Ready (Inspect) Visit Preview 💬 Add feedback Oct 17, 2024 3:07pm
8 Skipped Deployments
Name Status Preview Comments Updated (UTC)
examples-basic-web ⬜️ Ignored (Inspect) Visit Preview Oct 17, 2024 3:07pm
examples-designsystem-docs ⬜️ Ignored (Inspect) Visit Preview Oct 17, 2024 3:07pm
examples-gatsby-web ⬜️ Ignored (Inspect) Visit Preview Oct 17, 2024 3:07pm
examples-kitchensink-blog ⬜️ Ignored (Inspect) Visit Preview Oct 17, 2024 3:07pm
examples-native-web ⬜️ Ignored (Inspect) Visit Preview Oct 17, 2024 3:07pm
examples-svelte-web ⬜️ Ignored (Inspect) Visit Preview Oct 17, 2024 3:07pm
examples-tailwind-web ⬜️ Ignored (Inspect) Visit Preview Oct 17, 2024 3:07pm
examples-vite-web ⬜️ Ignored (Inspect) Visit Preview Oct 17, 2024 3:07pm

@tknickman
Copy link
Member

Fixes #9211

@chris-olszewski chris-olszewski merged commit 791a033 into main Oct 17, 2024
40 checks passed
@chris-olszewski chris-olszewski deleted the olszewski/perf_move_tui_tokio branch October 17, 2024 15:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants