KFileItem optimization

Peter Penz peter.penz at gmx.at
Mon Jan 5 09:43:47 CET 2009


Hi,

-------- Original-Nachricht --------
> Datum: Mon, 5 Jan 2009 00:08:15 +0100
> Von: "Fredrik Höglund" <fredrik at kde.org>
> An: Jakub Stachowski <qbast at go2.pl>
> CC: kde-optimize at kde.org, Peter Penz <peter.penz at gmx.at>
> Betreff: Re: KFileItem optimization

> On Sunday 04 January 2009 13:30, Jakub Stachowski wrote:
> > Dnia Saturday 03 January 2009, Jakub Stachowski napisał:
> > > Hello,
> > [ ... ]
> > 
> > >  Another possible optimization: for each item, KFileItemDelegate
> > > checks
> > > actual size of file icon. Is this really necessary? Or maybe it would
> > > be
> > > enough to check size for first icon in the view and then reuse it.
> > 
> > Some more checking shows that for given decoration size (stored in 
> > option.decorationSize), actual icon size is always the same - one of 
> > the 
> > common sizes like 64x64, 256x256 etc.
> > Caching the size makes laying out items about 20% faster (on top of
> > previous 
> > patch).
> > KFileItemDelegate objects are not created in great numbers (one per
> > view), so 
> > adding two QSize fields will not have any effect on memory usage.
> 
> Hi Jakub,
> 
> Unfortunately that assumption isn't true when previews are enabled.
> KFileItemDelegate::sizeHint() used to rely on option.decorationSize and
> never load the icon, but that optimization didn't work because
> of that reason.
> 
> I'm CC'ing Peter Penz in case he has something to add, because if my
> memory serves me right he did the original analysis of that issue.

I did not follow the whole mail thread, but yes: I did some analyzes for Dolphin around 9 months ago. I think Fredrik is right here...

If I remember correctly the real bottleneck is in QListView itself, it calls the size hint more often than it needs to call it. When QListView::setGridSize() is used, the size hint does only need to get called for the visible items, but it is called for all of them. It gets really nasty when changing a single icon if the listview is already open: In this case QListView calls the size hint for all (!) items on each icon change. This got a big issue when generating previews. I could bypass this by calling QListView::setUniformRowSizes(true) before applying a patch of icons (and calling QListView:.setUniformRowSizes(false) before the event loop gets entered again and relayout is called). But this is a workaround and should really be fixed in QListView...

Regards,
Peter

> Regards,
> Fredrik


More information about the Kde-optimize mailing list