[PATCH] Speed up iconView's setIcons 2x...

Maks Orlovich mo002j at mail.rochester.edu
Tue Aug 13 20:39:38 BST 2002


Hi...

Currently, there are some cases in which Konqueror used as a filemanager 
performs quite horridly. One of them was pointed out by Qwertz on IRC: open a 
local webpage, and click back to a large directory. I've tried that, and here, 
on a Celery 950 it takes *3 seconds* to do that -- and during that time the 
event loop seems stalled, which means some of the toolbar (where the KHTML 
merged icons were) is not repainted, and there is an ugly flat rectangle on 
the screen).. I've examined that, and basically, all the work is being done 
in KonqKfmIconView::doOpenURL, which get called through a number of fast 
intermidaries when restoring view state.. There, there are basically three 
major time spenders:

1. dirLister->openURL, which takes 600-800ms (probably worth a look)
2. newIconSize( m_pProps->iconSize() )-- this currently takes 2 seconds; my 
patch improves it to about 550ms-600..
3. About 65 ms spent on m_pProps->applyColors( m_pIconView->viewport() );

I've focused on 2, and this is what the patch addresses. AN another question 
is why these time consuming tasks are performed in such a blocking fashion. 

There, virtually all of the work done is in KonqIconViewWidget::setIcons, 
where a loop runs through all entries, and sets their icons, telling them to 
recalculate and repaint.. The problem is, the paints are both useless and 
redundant.. At this point in time, my debug shows that the icon view item's 
aren't yet layed out, and so are all at 0,0; where of course they'll not stay 
after getting layed out below; and further, thaty means that every single of 
the icons is painted -- despite the fact that my view is nowhere near large 
enough to show 1000 of files.. And further, the grid re-layout below causes a 
full repaint most of the time anyway. 

To makes things worse, there appears to be an obvious but in the QIconViewItem 
method libkonq using: it's calculating the new rectangle twice when we're 
calling it with both redraw and recalc (and it also likely fails to repaint 
the old rectangle due to that); and that is extremely expensive since the 
calculations needs to find the way to wrap the text; the code in question is: 


    if ( recalc )
	calcRect();
    if ( redraw ) {
	if ( recalc ) {
	    QRect oR = rect();
	    calcRect();
	    oR = oR.unite( rect() );


Thus, the speed up from the attached patch is considerable. It reduces the 
time to apply the icons here to about 600ms; about 200ms of that is due to 
loading/getting the pixmaps, and the 400ms left is basically due to 
calcRect() calling boundingRect(0 of its font metrics to ask it to wrap the 
text. Since the latter involves the rich-text path of qt_format_text I'll 
pass on that.. And anyway, overall, this seems to cut the overallt imes to 
1.5 seconds - in half.. 


Comments, thoughts, suggestions? Should I bug the Trolls about the above code 
in Qt?


Thanks,
Maks Orlovich




-------------- next part --------------
A non-text attachment was scrubbed...
Name: speedup_iconview_set_icons.diff
Type: text/x-diff
Size: 1155 bytes
Desc: not available
URL: <https://mail.kde.org/mailman/private/kfm-devel/attachments/20020813/094e47eb/attachment.diff>


More information about the kfm-devel mailing list