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

Performance improvements #1127

Open
SBoudrias opened this issue Jun 18, 2022 · 0 comments
Open

Performance improvements #1127

SBoudrias opened this issue Jun 18, 2022 · 0 comments

Comments

@SBoudrias
Copy link
Owner

SBoudrias commented Jun 18, 2022

I had 2 ideas to improve the performance of the new core (but not sure if they'll work.)

This could help alleviate perf concerns raised in a few issues (like #408) once we release the Inquirer rewrite.

Debouncing re-renders

The current hook implementation will always trigger a synchronous re-render. I think debouncing this slightly will help improve performance when multiple setState are called after each other.

This logic lives over here, the idea would be to review the handleChange implementation to maybe schedule a re-renders on a different loop that's debounced or timer base.

Contributions welcomed if you'd like to tackle!

Diff based re-rendering

On each re-renders, Inquirer clears the whole prompt content and re-renders it all. This is how the ScreenManager is implemented ATM.

I think we could be smarter and do a diff line by line and only clear/re-renders line by line. And we could even only re-renders the line from the point where it changes (comparing strings chars by chars.)

But there's 2 risks with this solution:

  1. This will prevent us from bundling lines clear & cursor operations together
  2. This will make the cursor position management logic more complicated

So it's an uncertain performance improvement... It could also lead to slower performance if the bundling of actions help the terminal render faster. It's unfortunate that terminals perform so differently between implementations and are kinda unknown compared to how well we understand browsers paint cycles today.


Any other ideas from you?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant