-
-
Notifications
You must be signed in to change notification settings - Fork 102
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
Fast search #2179
base: main
Are you sure you want to change the base?
Fast search #2179
Conversation
I get a ton of new warnings on start with this branch about:
|
Ok the warnings should be fixed now. I also added some additional null checks that shouldn't trigger if we do it right but better safe than sorry :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Having a separate SearchEngine is awesome and definitely makes things more flexible. Love that!
It looks like in quite a few cases this branch doesn't use/breaks GObject-style construction so we want to make sure to maintain that
Is there a reason for making package
settable across all these classes? It seems like it adds quite a lot of complexity
public SearchEngine (Package[] packages, AppStream.Pool pool) { | ||
var unique_packages = new Gee.HashMap<string, Package> (); | ||
foreach (var package in packages) { | ||
var package_component_id = package.normalized_component_id; | ||
if (unique_packages.has_key (package_component_id)) { | ||
if (package.origin_score > unique_packages[package_component_id].origin_score) { | ||
unique_packages[package_component_id] = package; | ||
} | ||
} else { | ||
unique_packages[package_component_id] = package; | ||
} | ||
} | ||
|
||
this.packages.splice (0, 0, unique_packages.values.to_array ()); | ||
this.pool = pool; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we make sure we're using GObject-style construction here? https://docs.vala.dev/tutorials/programming-language/main/03-00-object-oriented-programming/03-14-gobject-style-construction.html
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah I didn't use it here because we don't need the packages array but only the liststore with the unique packages so it seemed kinda pointless to first put the array into a property and then in construct extracting this stuff and then setting the property to null to free the memory. Alternatively we could ofc do all of this in the flatpackbackend and hand over the liststore right away 🤷
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah that might be the way to go here so we can stick to coding conventions
action_stack = new ActionStack (); | ||
action_stack.package = package; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we do:
action_stack = new ActionStack (); | |
action_stack.package = package; | |
action_stack = new ActionStack () { | |
package = package | |
}; |
public InstalledPackageRowGrid (AppCenterCore.Package package, Gtk.SizeGroup? action_size_group) { | ||
Object (package: package); | ||
this.package = package; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oops don't break GObject-style construction here
if (package != null) { | ||
bind (package); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here, breaks GObject-style construction
The reason for making package settable was to enable recycling these widgets which is necessary for a performant listview with many packages. The big issue is that when using property setters and gobject style construction those will run before the construct block which means if we try to access widgets created there they are still null, which is why - to avoid duplicate code - I decided to break some gobject style construction . We could use notifies instead of using property setters to update stuff but that might increase complexity even more idk? I think in the long run it would probably be best to just port everything to listview/gridview and eventually get rid of constructing with a package alltogether. |
@leolost2605 would it make more sense then to make a new clean search list row widget that has a settable package instead of modifying all the way up through the abstract widgets that are used elsewhere? |
That would lead to a lot of duplicate code though (or loss of functionality). Maybe we should first port everything to the new views and then just hook up this fast search? |
Moves search from a slow and synchronous search to a fast and incremental search. This can range from just feeling a bit snappier for optimal searches for the old system like "firefox" to going from a 20 second search leading to a "Not responding" popup to a near instantaneous search.
We already have a list of available packages so why go the route via multiple reassignments and list creations etc. via the appstream pool if we can just do it ourselves. Yields the same search results and greatly improves performance. Also switch to a Gtk.ListView so we can handle the great number of apps we sometimes get. I've left the synchronous search in place since it's easier to user with search provider etc.
In the videos the part where I search for flat is admittedly an extreme case since almost all apps are returned there but we can still see that the new search doesn't take longer than a second (vs. 20 - 30 or so with GNOME Software or our old search) to completely fill the list.
Old (I didn't stop typing, the UI just completely blocked):
Kooha-2024-06-20-21-10-14.webm
New:
Kooha-2024-06-20-21-18-55.webm
GNOME Software:
Kooha-2024-06-20-21-16-31.webm