Skip to content

Performance improvements #1127

@SBoudrias

Description

@SBoudrias

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions