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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

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 Sep 10, 2024 7:00pm
8 Skipped Deployments
Name Status Preview Comments Updated (UTC)
examples-basic-web ⬜️ Ignored (Inspect) Sep 10, 2024 7:00pm
examples-designsystem-docs ⬜️ Ignored (Inspect) Sep 10, 2024 7:00pm
examples-gatsby-web ⬜️ Ignored (Inspect) Sep 10, 2024 7:00pm
examples-kitchensink-blog ⬜️ Ignored (Inspect) Sep 10, 2024 7:00pm
examples-native-web ⬜️ Ignored (Inspect) Sep 10, 2024 7:00pm
examples-svelte-web ⬜️ Ignored (Inspect) Sep 10, 2024 7:00pm
examples-tailwind-web ⬜️ Ignored (Inspect) Sep 10, 2024 7:00pm
examples-vite-web ⬜️ Ignored (Inspect) Sep 10, 2024 7:00pm

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