status-im / status-desktop

Status Desktop client made in Nim & QML
https://status.app
Mozilla Public License 2.0
287 stars 78 forks source link

[SFPM refactoring] Align the sorters implementation to improve performance and code quality #13373

Open alexjba opened 7 months ago

alexjba commented 7 months ago

Description

Related discussions: https://github.com/status-im/SortFilterProxyModel/pull/3#pullrequestreview-1854110886 https://github.com/status-im/status-desktop/pull/13360#discussion_r1473055545

The purpose of this task is to refactor the SortFilterProxyModel sorters and filters to improve performance code quality.

There are 3 main points to be addressed in this task:

  1. Use delayed invalidate by default. Currently the FastExpressionSorter is using a delayed invalidate to avoid unnecessary sorting until the event queue is cleared. The same approach is available by configuration in SortFilterProxyModel. Ideally all Sorters/Filters should behave the same in terms of delaying the invalidate. I see two options: either SortFilterProxyModel should use a delayed invalidate, or enable the delayed invalidate in the sorters/filters. An investigation and profiling is needed to find the best approach.

  2. Use a more efficient way to expose context properties to js expressions. In this PR https://github.com/status-im/status-desktop/pull/13360 FastExpressionSorter was updated to reuse the same context properties when exposing model data to js expressions. A QQmlPropertyMap is used as context property and only the properties in this map are updated. The context is not changed.

  3. Can we use a more efficient way to do deal with the 3 way comparison needed when there's multiple sorters with different priorities?

caybro commented 4 months ago

Is this still valid/open @alexjba ?

alexjba commented 4 months ago

Is this still valid/open @alexjba ?

Yes, let's keep it. At least to do an analysis on these points.