ListView performance: lots of re-binds
Thank you for the addition of the awesome ListView in Gtk4. It is a massive step forward compared to Gtk3.
I am still facing a minor issue with it, though. I already opened a topic at discourse.gnome.org but here is a summary:
- In NewsFlashs gtk4 port I have a list with relatively complex items, but only very few of them are visible at the same time
- Example of a typical ListView
- They are all the same height, so calculating how many are visible given the parent ScrolledWindow should be easy
- After a sync it is not uncommon to add >200 items on top of the list
- Each and every item that is added to the top of the list triggers a re-bind of up to 204 items (
GTK_LIST_VIEW_MAX_LIST_ITEMS
+ 2 *GTK_LIST_VIEW_EXTRA_ITEMS
) = >200 * 204 re-binds - Luckily my items all have a GUID and most of the binds are re-binds with the same data so I can avoid most of the work (I was able to optimize further after the discourse topic). If that weren't the case I would face update times of multiple seconds at least.
- I am still left with update-times of the ListView of >300ms when adding before mentioned >200 items on top (potentially much longer in extreme cases)
As someone who doesn't know the internal workings of ListView well, I see two ways of improving the situation for my use-case:
- Allow setting of custom value for
GTK_LIST_VIEW_MAX_LIST_ITEMS
from outside (I could probably cut this down by a factor 10 for my use-case) - Have some property of ListView that tells it the items have a homogeneous height. That way the amount of items that need to be shown can be calculated dynamically relatively cheap by measuring just one row.
I understand that this is not the highest priority issue, but I hope it is still a valid concern.