[KPhotoAlbum] Search improvements

Robert Krawitz rlk at alum.mit.edu
Tue Oct 16 04:55:25 CEST 2018


I've gotten a significant improvement in search performance; a search
that used to take 20 seconds now takes about 4.  That's within range
of what I was expecting (factor of 6 or 7).

My strategy is to cache search results, since the same search is
performed once per category, and additionally it's called once before
even reaching updateImageCount.  However, this is a bit tricky,
because there's another match performed for the "no other", and that
search would kick out the cache result.  So I've added a method to
make searches uncached.

The cache is implemented by means of a generation count.  All of the
non-const ImageSearchInfo calls (except for the copy constructor)
cause the generation count to be incremented, and the current value of
that is stored in the ImageSearchInfo.  The cache is checked only when
the generation number stored in the ImageSearchInfo matches the
generation number stored in the ImageInfo.  It's probably harder to
explain than it is to read the code.

Anyway, I've pushed this as the search-performance branch, for
everyone's enjoyment.

I notice that a lot of the stuff in image search uses maps rather than
hashes.  Maps perform better in QT5 than previously, but for more than
maybe 20-30 elements, hashes still do better.  I don't know if anyone
has looked at this, but it may be something to think about.  Fast
searches are an essential part of KPA.
-- 
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