Bug 333563 - Telepathy contactlist is too fast to filter/search as you type; makes UI unresponsive on 1000s contacts
Summary: Telepathy contactlist is too fast to filter/search as you type; makes UI unre...
Status: CONFIRMED
Alias: None
Product: telepathy
Classification: Frameworks and Libraries
Component: contactlist (show other bugs)
Version: 0.8.0
Platform: Kubuntu Linux
: NOR minor
Target Milestone: Future
Assignee: Telepathy Bugs
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-04-18 02:47 UTC by Fabio Correa
Modified: 2021-03-09 07:26 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments
Callgrind logs for filtering (900.82 KB, application/octet-stream)
2014-04-28 20:08 UTC, David Edmundson
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Fabio Correa 2014-04-18 02:47:12 UTC
I have 3000ish contacts and when I do a search in the Filter box, each keystroke triggers the filtering algorithm.

Reproducible: Always

Steps to Reproduce:
1. Enable several accounts to get 1000 of contacts.
2. Open the contactlist; start a search/filter with Ctrl+F
3. Write a name at normal typing speed.

Actual Results:  
You notice that a search is performed on each keystroke.


Expected Results:  
The Filter algorithm should be delayed for half a second or so, to allow the user to type his search terms keeping the UI responsive. Then some UI feedback code should show the window as busy while searching.


Workaround: I write my search terms in kwrite and then copy them to the filter box; this is much faster and more responsive.

This is just a minor annoyance. KDE Telepathy has become my IM platform of choice. Keep up the good work.
Comment 1 Martin Klapetek 2014-04-18 07:40:25 UTC
Thanks for the report. 

I can confirm this happening. I guess we could add a simple

if (contacts.size() > 500) {
   delaySearching();
}

Btw. in the meantime you can also use KRunner to search for your contacts, that should be way more responsive ;)
Comment 2 David Edmundson 2014-04-27 23:34:15 UTC
We've made some parts of the model faster. Please retest to see if this is actually needed.
Comment 3 Fabio Correa 2014-04-28 15:35:33 UTC
Thanks for your work. Tested your git commit 593a1a48 and there's no change in search responsiveness.
Comment 4 David Edmundson 2014-04-28 16:19:27 UTC
Thanks. Can you check you have 1417fd90f1b07de2badf3cf4ff208c8da1702c60 in libkpeople too? 

This is the one that makes data() faster, the commit you linked was purely for grouping.

I'd like to try and optimise before we add in a workaround; it'll make all the things faster. There was some work to do in the KTpTranslationProxyModel.
Comment 5 Fabio Correa 2014-04-28 18:45:54 UTC
Sorry; I was using the downstream libraries. I compiled the libkpeople master and the situation improved considerably; search took ~3 seconds before, now it takes ~1 sec on the first letter.
Comment 6 David Edmundson 2014-04-28 20:07:20 UTC
I've got a callgrind output from just the filtering.

We are spending a /lot/ of time in QImage::load()  (30% of my time filtering)
we call it more often that we call paintRow. Which means something is wrong.

QPixmap has an implicit cache when given a path, QImage does not; we are probably loading a whole image every time we repaint.

We spend 9% of the time in QPixmap::scaled() so maybe we should keep a QPixmapCache of the scaled avatars. That really means changing the API from libkpeople, as we would need some sort of string identifier for the image.

Lets fix that, it'll probably give us a boost, and then we can look and see if we need to optimise anything else.
Comment 7 David Edmundson 2014-04-28 20:08:10 UTC
Created attachment 86320 [details]
Callgrind logs for filtering
Comment 8 David Edmundson 2014-04-28 20:26:00 UTC
We spend another 9% of the time in KTp::dataForKtpContact.

This code is relatively slow; which is fine as it's only meant to be used when we are invoking an action.
The sorting function includes ContactClientTypesRole, which goes via this function, it ends up getting called > 9000 times whilst I was searching.

If we proxy the clientTypes as a custom field in libkpeople we will save a lot.
Comment 9 David Edmundson 2014-04-28 20:30:00 UTC
Sorry for the noise:
>That really means changing the API from libkpeople, as we would need some sort of string identifier for the image.

Edit: QPixmap::cacheKey solves that.
Comment 10 Justin Zobel 2021-03-09 07:26:17 UTC
Thank you for the bug report.

As this report hasn't seen any changes in 5 years or more, we ask if you can please confirm that the issue still persists.

If this bug is no longer persisting or relevant please change the status to resolved.