[KPhotoAlbum] More on thumbnails

Kerry Sainsbury kerry at fidelma.com
Fri May 18 08:33:35 BST 2018


I have to say that I'm really enjoying the commentary. Thanks for the
taking the time to not only fix stuff, but also to write it up!

Perhaps I need to get out more.

On 18 May 2018 at 13:20, Robert Krawitz <rlk at alum.mit.edu> wrote:

> There are some really serious problems in the thumbnail cache code:
>
> 1) It misuses timers.  Timers can only be started and stopped in the
>    same thread.  Even putting them all in the same function is not
>    good enough, if that function can be called from different threads;
>    with the multi-threaded nature of thumbnail building, calling
>    ThumbnailCache::save() directly means it can be called from
>    multiple threads.
>
>    The practical impact is that the 1-second timer for thumbnail
>    saving accomplished nothing, because the timer was seldom getting
>    started (or stopped).
>
>    The solution is to never call save() directly; always call it
>    indirectly through emitting a signal.
>
> 2) The thumbnail cache itself is saved very inefficiently; it's
>    written in full to a temporary file, which is then copied (yes,
>    copied, not renamed) to the real file.  Even with a big database,
>    such as my own (270,303 images) that's probably not killing me with
>    I/O, but it's a lot of work to be doing every 100 images.
>
>    I'm changing it to do an incremental save where possible.  That
>    technically violates the intent of the file format, which stores
>    the most recently written file and offset as well as the image
>    count, but those can be reconstituted on cache reload easily
>    enough.
>
>    Also, in order to do that, I had to add an additional list of
>    unsaved files (auto-save list).  And there's no good reason for the
>    data structure to be a QMap; a QHash is faster, and ordering
>    doesn't matter in the cache.
>
> 3) The save() routine wasn't protected by a mutex; with multiple
>    threads processing thumbnails, I'm not sure how we didn't get a lot
>    of data corruption in the index cache.
>
> I'm working on all of these problems.
>
> --
> 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
> _______________________________________________
> KPhotoAlbum mailing list
> KPhotoAlbum at mail.kdab.com
> https://mail.kdab.com/mailman/listinfo/kphotoalbum
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/kphotoalbum/attachments/20180518/a969649b/attachment.htm>


More information about the Kphotoalbum mailing list