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 312581 - Optimise string manipulation in vcard parsing
Optimise string manipulation in vcard parsing
Status: RESOLVED FIXED
Product: evolution-data-server
Classification: Platform
Component: Contacts
1.2.x (obsolete)
Other Linux
: High major
: ---
Assigned To: evolution-addressbook-maintainers
Evolution QA team
Depends on:
Blocks:
 
 
Reported: 2005-08-04 14:04 UTC by Ross Burton
Modified: 2018-12-11 12:52 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Optimise string handling (8.73 KB, patch)
2005-08-04 14:04 UTC, Ross Burton
none Details | Review
Improved patch (10.11 KB, patch)
2005-08-11 09:48 UTC, Ross Burton
none Details | Review

Description Ross Burton 2005-08-04 14:04:05 UTC
It turns out that vCard parsing is quite a bottleneck in the addressbook. 
Attaching a patch to:

* Reduce the number of g_string_append_unichar() calls (which turn into a memcpy) 
* Replace _append_ with _insert_ (-1) to save the overhead of another function
call and type check
* Stop using the return value of g_string_* (as its only returned for convenience)
Comment 1 Ross Burton 2005-08-04 14:04:31 UTC
Created attachment 50230 [details] [review]
Optimise string handling
Comment 2 Brent Smith (smitten) 2005-08-04 22:07:20 UTC
marking new, and setting priority to high because of the patch.
Comment 3 Ross Burton 2005-08-11 09:48:34 UTC
Created attachment 50568 [details] [review]
Improved patch

This patch rewrites the vCard parser, and doesn't duplicate the string several
times before parsing.  It needs testing and many eyes. Shame there isn't a
decent unit test suite for vCard parsing.
Comment 4 Ross Burton 2005-08-11 09:53:14 UTC
Forgot to attach the benchmark.  Parsing a vCard 100000 times with the old code
takes 8.4 seconds, and 4.4s with this patch.
Comment 5 Not Zed 2005-08-19 03:21:19 UTC
I wonder, given that there is no vcard regression test right now, if one can't
be created?  It would be a good opportunity I think.

I would certainly feel more comfortable with a parser change if there was a good
verification suite for it.
Comment 6 André Klapper 2005-11-14 23:41:59 UTC
adding perf keyword
Comment 7 Harish Krishnaswamy 2006-07-10 11:09:27 UTC
Devashish/Sushma : ?
Comment 8 André Klapper 2006-07-15 09:57:06 UTC
harish: please don't use NEEDINFO state if input from developers is needed. please use it only for reporters. use ASSIGNED state instead. thanks in advance. :-)

devashish/sushma: ping
Comment 9 André Klapper 2006-07-15 09:58:44 UTC
ross: is that patch already in use at openedhand?
Comment 10 Ross Burton 2006-07-15 10:05:22 UTC
Yes.  A derivitive of this patch is on the Nokia 770.
Comment 11 André Klapper 2006-07-15 10:18:20 UTC
ross, i just asked because you wrote "it needs testing and many eyes". thanks. :-)

devashish/sushma: ping! please review the patch...
Comment 12 André Klapper 2006-08-23 11:06:13 UTC
definitely a 1.8 or 1.9 target.
Comment 13 Kjartan Maraas 2007-01-25 14:18:32 UTC
Can we please get this reviewed/commited?
Comment 14 Ross Burton 2007-05-11 17:49:29 UTC
Latest svn, once #433782 lands, contains a partial fix for this which is very nice.  I need to re-sync and refactor this patch.
Comment 15 Kandepu Prasad 2008-08-06 05:38:24 UTC
Any updates? Is the issue resolved? TIA.
Comment 16 Kjartan Maraas 2010-12-16 16:58:48 UTC
Lowering severity since this has been partially fixed already. Are there still relevant bits in this patch?
Comment 17 Milan Crha 2018-12-11 12:52:31 UTC
I tried to do similar changes as Ross in his latest patch (which has at least one bug, a call of g_string_assign (str, ""); after freeing it with g_string_free()), though it didn't do as significant improvement as the Ross' patch in the past. It shrunk parsing of a 2.6KB vCard 100K times from 13.7s to 9.8s (28%), which is not as that much as Ross' attempt (47.6%). Maybe it's because I used a different vCard data, I do not know. The code also changed meanwhile, especially that about unfolding, thus that could have its impact as well.

It's possible there's still some room for improvements, though I do not see it at the moment.

Created commit f2b976db9 in eds master (3.31.4+)