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 271113 - Contact searching is very slow.
Contact searching is very slow.
Status: RESOLVED FIXED
Product: evolution
Classification: Applications
Component: Contacts
unspecified
Other All
: Normal normal
: ---
Assigned To: evolution-addressbook-maintainers
Evolution QA team
Depends on: 312690
Blocks: 327508 327510
 
 
Reported: 2005-01-09 04:07 UTC by Nat Friedman
Modified: 2013-09-10 14:04 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
patch to test (3.84 KB, patch)
2005-01-13 12:32 UTC, Sivaiah
committed Details | Review
fix for is full_name query (997 bytes, patch)
2005-01-13 16:08 UTC, Sivaiah
none Details | Review
A graph of query times (6.93 KB, image/png)
2005-01-17 06:49 UTC, Nat Friedman
  Details

Description Nat Friedman 2005-01-09 04:07:11 UTC
Simple field-test searches on a ~500 contact local addressbook take between
0.10 and 0.50 seconds on my pretty nice computer.  These times are for a
synchronous call to e_book_get_contacts.  One-tenth of a second may sound
speedy, but even a small number of searches (say, 10) add up quickly.

This particularly plagues the BBDB e-plugin (evolution/plugins/bbdb) which
appears to lock up when you reply to messages with large recipient lists,
because so much time is spent synchronously querying the addressbook.

One solution might be to make the BBDB plugin run in a thread, but this
will doubtless introduce all kinds of new complexity, and will still leave
us with slow query performance in Evolution's addressbook.  So I decided to
poke around inside the beast.

As far as I can tell, here's what happens when you call e_book_get_contacts:

1. The query is passed to the file backend: e-book-backend-file.c,
e_book_backend_file_get_contact_list().  It is sent over CORBA.

2. The db3 database is opened.  The backend iterates over every single
record in the database and:

2a. Reads the entire vcard out of the database (including embedded base64
images).

2b. Converts the vcard to an EContact: e-book-backend-sexp.c,
e_book_backend_sexp_match_vcard().

2c. Runs the sexp query against the EContact.

2d. Destroys the EContact.

2e. If the query matched the EContact, the entire vcard string is added to
a list of matches.

3. When all the vcard match strings are collected, they get sent over CORBA
 to the caller: e-data-book.c, e_data_book_respond_get_contact_list().

4. The list of vcard strings is then converted to EContacts on the client
side: e-book-listener.c, impl_BookListener_respond_get_contact_list().

5. e_book_get_contacts returns the list of EContacts.

Step 2b seems to consume 70-90% of the total query time, based on some
GTimer instrumentation.

Probably the best way to fix this is to augment or replace the db3 database
with a searchable index of commonly-searched fields.  I noticed there is an
addressbook.db.summary file already in my ~/.evolution.  I'm not sure what
that's all about.

Another option would be to just do a full-text search of the vcard strings,
instead of converting to an EContact.  For example, when someone searches
for (is "email" "nat@nat.org"), you could search the vcard text for
"EMAIL:nat@nat.org^M".
Comment 1 Nat Friedman 2005-01-09 04:09:48 UTC
I should also note that I noticed while I was in there that I am
listed as the sole author of many of those files, most of which I
haven't touched in nearly five years.  Which I think is because no one
else has wanted to take responsibility for them.  :-)
Comment 2 Sivaiah 2005-01-13 12:32:41 UTC
Created attachment 44560 [details] [review]
patch to test
Comment 3 Sivaiah 2005-01-13 12:37:40 UTC
attached patch uses summary in case of get_contact_list also, i have
tried "(is \"email\" \"foo@bar\")" "beingswith \"full_name\" \"foo\")"
queries 
and things seems to faster with summary. Full name comparioson   in
summary seems to be different from e_book_backend_sexp_match_contact
and look broken. So "(is \"full_name\" \"foo\")" queries do not return
results when complete name is given as part of the query with the
above patch . But that is a totally different issue to be fixed in
summary.

Comment 4 Nat Friedman 2005-01-13 15:04:34 UTC
This patch seems to improve query performance for email and full name
searches by 2 orders of magnitude.  Really, really nice.
Comment 5 Sivaiah 2005-01-13 16:08:06 UTC
Created attachment 44561 [details] [review]
fix for is full_name query
Comment 6 Nat Friedman 2005-01-17 06:49:30 UTC
Siva's patches seem to be in HEAD now.

For 127 sequential searches against email/full_name, I get an average
search time of 0.014 secs, which is at least 10x better than what we
saw without the summary files.  Max was 0.0858, min was 0.00128.

What's strange is the queries seem to get slower over time.  I'll
attach a graph.
Comment 7 Nat Friedman 2005-01-17 06:49:56 UTC
Created attachment 44568 [details]
A graph of query times
Comment 8 Nat Friedman 2005-01-19 08:21:56 UTC
Someone suggested that the query time spikes we see around query #85
are due to EDS spawning new threads for each search.

This is possible, but seems strange considering that these are
sequential, synchronous (not simultaneous/async) queries.
Comment 9 Gerardo Marin 2005-01-30 02:50:41 UTC
Not sure if this can be closed now, since patch made head and seems to
solve the problem.
Comment 10 André Klapper 2005-06-07 12:01:24 UTC
nat, are you content with closing this one here? at least punting target
milestone from 2.1 to 2.2.x.
Comment 11 Sushma Rai 2005-08-27 10:38:14 UTC
patch at 312690 would help to improve the performance.
Comment 12 André Klapper 2005-10-14 14:49:01 UTC
adding perf keyword
Comment 14 Kjartan Maraas 2006-08-08 13:11:38 UTC
The patch in bug 312690 was commited as well. Can we close this? Or at least mark the patches as commited if they really are in CVS?
Comment 15 André Klapper 2006-08-21 19:38:02 UTC
first patch has been committed:
http://cvs.gnome.org/viewcvs/evolution-data-server/addressbook/backends/file/e-book-backend-file.c?r1=1.26&r2=1.27

issue of the second patch has also been already fixed in the code.

closing this bug as fixed.


kmaraas: thanks for poking. :-)