After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 695648 - Utils: add a fast-path for empty sets and multimaps
Utils: add a fast-path for empty sets and multimaps
Status: RESOLVED FIXED
Product: folks
Classification: Platform
Component: libfolks
git master
Other Linux
: Normal enhancement
: Unset
Assigned To: folks-maint
folks-maint
Depends on:
Blocks:
 
 
Reported: 2013-03-11 18:34 UTC by Simon McVittie
Modified: 2013-03-13 12:59 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
collection comparators: optimize the case of empty collections (1.88 KB, patch)
2013-03-11 18:34 UTC, Simon McVittie
accepted-commit_now Details | Review
collection comparators: optimize the case of empty collections (2.17 KB, patch)
2013-03-12 17:11 UTC, Simon McVittie
committed Details | Review

Description Simon McVittie 2013-03-11 18:34:30 UTC
Created attachment 238611 [details] [review]
collection comparators: optimize the case of empty  collections

Comparing integers is a lot faster than constructing one or more
GObjects to iterate over the hash table. This saves about 3% of the
user CPU time needed to deal with 2049 simple e-d-s Google contacts,
each with one email address and no phone numbers etc.
Comment 1 Philip Withnall 2013-03-11 20:10:02 UTC
Review of attachment 238611 [details] [review]:

Would be useful to add a note that the zero comparison is to avoid creating an iterator. Apart from that, this looks like a handy optimisation. Please commit to master!
Comment 2 Philip Withnall 2013-03-11 20:10:38 UTC
(In reply to comment #1)
> Please commit to master!

*remembering to update NEWS.
Comment 3 Simon McVittie 2013-03-12 14:56:58 UTC
Unfortunately, this makes a couple of the e-d-s tests time out. Looking into it...
Comment 4 Simon McVittie 2013-03-12 17:11:56 UTC
Created attachment 238719 [details] [review]
collection comparators: optimize the case of empty  collections

Comparing integers is a lot faster than constructing one or more
GObjects to iterate over the hash table. This saves about 3% of the
user CPU time needed to deal with 2049 simple e-d-s Google contacts,
each with one email address and no phone numbers etc.

---

Now with comments as requested, and fixing a stupid bug caught by the tests.
Comment 5 Simon McVittie 2013-03-12 17:14:42 UTC
(In reply to comment #4)
> Now with comments as requested, and fixing a stupid bug caught by the tests.

(and yes I've checked that it's still equally fast - the speed-up wasn't caused by that bug :-)
Comment 6 Philip Withnall 2013-03-13 09:40:06 UTC
Review of attachment 238719 [details] [review]:

Go for it.
Comment 7 Simon McVittie 2013-03-13 12:59:08 UTC
Comment on attachment 238719 [details] [review]
collection comparators: optimize the case of empty  collections

f2a0df2d22
Comment 8 Simon McVittie 2013-03-13 12:59:41 UTC
Fixed in git for 0.9.2