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

Fast search #2179

Open
wants to merge 20 commits into
base: main
Choose a base branch
from
Open

Fast search #2179

wants to merge 20 commits into from

Conversation

leolost2605
Copy link
Member

@leolost2605 leolost2605 commented Jun 20, 2024

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

@leolost2605 leolost2605 marked this pull request as ready for review June 20, 2024 19:33
@leolost2605 leolost2605 requested a review from a team June 20, 2024 19:33
@danirabbit
Copy link
Member

danirabbit commented Jun 20, 2024

I get a ton of new warnings on start with this branch about:

** (io.elementary.appcenter:128313): CRITICAL **: 13:36:51.569: app_center_core_package_get_is_local: assertion 'self != NULL' failed

** (io.elementary.appcenter:128313): CRITICAL **: 13:36:51.584: app_center_core_package_get_name: assertion 'self != NULL' failed

** (io.elementary.appcenter:128313): CRITICAL **: 13:36:51.584: app_center_core_package_get_summary: assertion 'self != NULL' failed

@leolost2605
Copy link
Member Author

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 :)

Copy link
Member

@danirabbit danirabbit left a 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

Comment on lines +17 to +32
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;
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member Author

@leolost2605 leolost2605 Jun 21, 2024

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 🤷

Copy link
Member

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

Comment on lines +213 to +214
action_stack = new ActionStack ();
action_stack.package = package;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we do:

Suggested change
action_stack = new ActionStack ();
action_stack.package = package;
action_stack = new ActionStack () {
package = package
};

Comment on lines 27 to +28
public InstalledPackageRowGrid (AppCenterCore.Package package, Gtk.SizeGroup? action_size_group) {
Object (package: package);
this.package = package;
Copy link
Member

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

Comment on lines +24 to 27
if (package != null) {
bind (package);
}
}
Copy link
Member

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

@leolost2605
Copy link
Member Author

leolost2605 commented Jun 21, 2024

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.

@danirabbit
Copy link
Member

@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?

@leolost2605
Copy link
Member Author

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?

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.

2 participants