]> git.0d.be Git - empathy.git/commit
contact list: optimize loading contacts
authorAlban Crequy <alban.crequy@collabora.co.uk>
Thu, 25 Aug 2011 15:46:25 +0000 (16:46 +0100)
committerAlban Crequy <alban.crequy@collabora.co.uk>
Mon, 29 Aug 2011 13:12:37 +0000 (14:12 +0100)
commitd2d6157547f7d386fea7721b4391b4d0c2b0d79b
tree8bb305848cdbefbf9b36c5d16278b4f1775f1b35
parent6a818ee5aced7076786ba0a48a8f32b800b9a676
contact list: optimize loading contacts

The previous algorithm was O(n^2) with the number of contacts. Each contact can
be in several groups, so when a contact is added or updated, we iterated over
all the contact list to find the rows representing the contact. When connecting
to an account and getting all the contacts, this was too slow.

The groups are stored in the GtkTreeStore and suffer from the same problem: to
look for a group, it needed to iterate on all contacts.

The new algorithm maintains a hash from the contact to the list of rows
representing it, and another hash from the group to the row representing it.

On Empathy 2.30.2 when tested on MeeGo with 300 contacts, loading the contacts
is faster: roughly 9 seconds before the patch, 3 seconds after.

On Empathy 3.1.5, it seems to load in background so I don't know how to measure
the time lost in GtkTreeStore. But before the patch, GProf says 23% is lost in
individual_store_find_contact_foreach(), and after the patch it is not visible
anymore. And "time" says we win 5s of CPU when starting+quitting Empathy:

      Before the patch:        After the patch:
      real    0m23.485s        real    0m23.460s
      user    0m13.805s        user    0m8.305s
      sys     0m0.308s         sys     0m0.316s

https://bugzilla.gnome.org/show_bug.cgi?id=657086
libempathy-gtk/empathy-contact-list-store.c
libempathy-gtk/empathy-individual-store.c