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

Optimize UI responsiveness in scanning state #209

Merged
merged 2 commits into from
Jan 5, 2024

Conversation

unixzii
Copy link
Contributor

@unixzii unixzii commented Jan 5, 2024

The UI is very laggy while the scanning is in progress, and it makes the program almost unusable during the first few seconds of startup. The bottleneck is jwalk iterator, it may block the UI thread sometimes. In this PR, I alleviated the situation by some optimizations, and the UI is now super responsive at startup.

Here is what it looks like:

Screen.Recording.2024-01-05.at.19.41.10.mov

Some implementation notes:

  • The traversal operation is moved to another thread to prevent the UI thread from being blocked, and its results are sent to the UI thread via a channel.
  • Use crossbeam::channel to receive UI events and jwalk entries. In contract to std::sync::mpsc, we can select from a set of channels without busy polling using try_recv.
  • Created our own version of input_channel. The function provided by crosstermion returns a std::sync::mpsc::Receiver value, which is not compatible with crossbeam::select!.

@gosuwachu
Copy link
Contributor

I have tested this change and indeed it is now super smooth 🎉 Thanks!

@Byron Byron merged commit 3c8a31b into Byron:main Jan 5, 2024
2 checks passed
@Byron
Copy link
Owner

Byron commented Jan 5, 2024

Thanks a million, it works just as advertised!

It's so good to have this issue finally fixed!

And because we had to wait so long for this to be improved, I didn't want anybody to wait even longer: here is the new release

@unixzii unixzii deleted the optimize-perf branch January 5, 2024 13:06
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

Successfully merging this pull request may close these issues.

3 participants