[KPhotoAlbum] Searching is very inefficient

Robert Krawitz rlk at alum.mit.edu
Mon Oct 15 03:37:25 BST 2018


Searching is very inefficient, particularly when there are many search
terms.

I'm doing an OR search for about 40 terms on my database of 280K
images, and it's taking about 20 seconds.  At a high level, it looks
like the match function is being called entirely too many times.  Part
of the problem is how DB::ImageDB::Classify (the XMLDB implementation
thereof) is being called 6 times, once for each category, and
apparently at least once more (since if I null out classify, it still
gets the right images).

Calling classify() on a pre-filtered list is looking thornier than I'd
like, and it looks like the classification isn't happening correctly.
What I think I'd like to do is implement a cache tristate on each
ImageInfo, where any change to the filter conditions invalidates the
cache.  But then I have to find every way the filter conditions can be
changed.  Hopefully that problem's tractable.

I'm still not sure after that whether 2 seconds for testing 40 filter
conditions against 280K images is reasonable.  That would be about 200
ns per filter test.  When I can get past this, I'll need to look at
the kcachegrind traces.
-- 
Robert Krawitz                                     <rlk at alum.mit.edu>

***  MIT Engineers   A Proud Tradition   http://mitathletics.com  ***
Member of the League for Programming Freedom  --  http://ProgFree.org
Project lead for Gutenprint   --    http://gimp-print.sourceforge.net

"Linux doesn't dictate how I work, I dictate how Linux works."
--Eric Crampton



More information about the Kphotoalbum mailing list