Re: Ad-filter loading and QRegExp performance
Lubos Lunak <[email protected]> Mon, 29 Jan 2007 16:41:03 +0100
| Newsgroups | gmane.comp.kde.devel.optimize,gmane.comp.kde.devel.kfm |
|---|---|
| Message-ID | <[email protected]> |
On Monday 29 January 2007 15:14, Robert Knight wrote: > Hello, > > Out of curiosity, I did a little profiling of Konqueror ( KDE 4 ) > startup recently using callgrind. > I was surprised to see that according to the output, about 5-10% of > the time is spent processing regular expressions for ad filters. Does this apply to KDE3 as well? > QRegExp seems to have a mechanism internally to delay parsing the > expression until it is needed ( ie. until indexIn() , exactMatch() or > a similar method is called on the regexp). Whenever a QRegExp is > copied, the engine preparation is performed first, so copying a > QRegExp loses the benefits of this delayed parsing. > KHTML stores the ad-filters in a QVector<QRegExp> internally, which > means copies inside Qt when using the append() method to add a new > filter to the internal list. This forces all ad-filter reg-exps to be > parsed on startup. > > Konqueror ships with almost 200 ad filters out of the box, and parsing > all of these takes some time. > > Initially I tried replacing QVector<QRegExp> with QVector<QRegExp*> > instead, but I realised that KHTMLSettings needs to be copied, and so > these pointers would need to be shared somehow. I am not sure of the > best way to do that. A simpler way should be storing also QVector<QString>, initially have QVector<QRegExp> empty and fill it only when it's needed for the first time. > The alternative, would be to modify the QRegExp code so that the > assignment operator did not automatically parse the reg exp. Who > should I get in touch with to discuss this? That indeed looks like the best choice. -- Lubos Lunak KDE developer -------------------------------------------------------------- SUSE LINUX, s.r.o. e-mail: [email protected] , [email protected] Lihovarska 1060/12 tel: +420 284 028 972 190 00 Prague 9 fax: +420 284 028 951 Czech Republic http//www.suse.cz