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

System trust filter is slow #684

Closed
jw3 opened this issue Dec 8, 2022 · 3 comments · Fixed by #738
Closed

System trust filter is slow #684

jw3 opened this issue Dec 8, 2022 · 3 comments · Fixed by #738
Assignees
Labels
performance trust ui Work related to the UI
Milestone

Comments

@jw3
Copy link
Member

jw3 commented Dec 8, 2022

The search bar to filter the system trust list is very slow once there are any significant number of entries.

20K entries is a good number for example.

@jw3 jw3 added trust ui Work related to the UI performance labels Dec 8, 2022
@jw3 jw3 added this to the v1.0 milestone Dec 8, 2022
@egbicker
Copy link
Contributor

egbicker commented Jan 5, 2023

It looks like the GTK refilter() on line 155 in searchable_list.py is likely the culprit of the search slowness.
Reference: https://docs.gtk.org/gtk3/method.TreeModelFilter.refilter.html

Time Delay

As far as the time delay goes, it appears that we are already using the GTK built-in delay for searches as described here: https://docs.gtk.org/gtk3/class.SearchEntry.html

To make filtering appear more reactive, it is a good idea to not react to every change in the entry text immediately, but only after a short delay. To support this, GtkSearchEntry emits the GtkSearchEntry::search-changed signal which can be used instead of the GtkEditable::changed signal.

https://docs.gtk.org/gtk3/signal.SearchEntry.search-changed.html

The GtkSearchEntry::search-changed signal is emitted with a short delay of 150 milliseconds after the last change to the entry text.

In glade/searchable_list.glade on line 39 we are using <signal name="search-changed" handler="on_search_changed" swapped="no"/>

Timing

For a System Trust DB with 35894 entries:

1 Character at a time

1 character (35894 -> 34244) ~38 seconds
2 characters (34244-> 12263) ~38 seconds
3 characters (12263 -> 559) ~4 seconds
4 characters (559 -> 545) ~0.3 seconds

Multiple characters

3 Characters (35894 -> 541 files) ~30 seconds
5 characters backspaced to 1 character (541 -> 34244 ) ~78 seconds
1 character to 3 characters after backspacing (34244 -> 958) ~68 seconds
3 characters to 5 characters (958 -> 545) ~0.3 seconds

@egbicker
Copy link
Contributor

egbicker commented Jan 10, 2023

@jw3 @dorschs57 How would you feel about checking the number of entries in the system trust db when we start the app and if there are more than some threshold (5k?) we display a button where the list is. The button would have text along the lines of "There are a large number of entries in the db. Please begin a search or press this to display all entries". I think this would let us start a search without going through every row to check visibility until there are fewer entries or let the user know performance might suffer.

@jw3
Copy link
Member Author

jw3 commented Jan 10, 2023

display a button where the list is.

Sounds like something that would go with #520 rather than this one.

short delay of 150 milliseconds

This sounds familiar. IIRC in gtk3 this cant be changed, in gtk4 it can.

If that was a 1 second delay it might make all the difference.

Two thoughts.

  1. Simple - Disable the changed event and instead use Enter keystroke event.
  2. Less simple - Stash a last-updated-time in the widget and use that to manually manage delay. It gets tricky at the last keystroke though.

I am wondering if (1) isn't just the best way until we see what changes as a result of #520.

?

@egbicker egbicker linked a pull request Jan 19, 2023 that will close this issue
@jw3 jw3 closed this as completed in #738 Mar 2, 2023
jw3 pushed a commit that referenced this issue Mar 2, 2023
Addresses slowness in search due to compounding search events by
changing the search bar behavior to only begin filtering when `Enter`
key is pressed instead of upon any key press.

The root cause of the slowness was multiple compounding search events
generated by the 150 millisecond keystroke delay. That is now eliminated
at the cost of having to press enter to initiate search.

Closes #684
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
performance trust ui Work related to the UI
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants