Ad-filter loading and QRegExp performance
Robert Knight
robertknight at gmail.com
Mon Jan 29 19:36:10 CET 2007
> Does this apply to KDE3 as well?
No, QRegExp handles copying differently in Qt 3.
> 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.
That makes sense, although at since there is plenty of time for TT to
improve QRegExp before KDE 4 is released, I will file a bug report.
Even if/when they are able to make this change, the regular
expressions still have to be parsed at some point before they can be
used to filter images out. It probably wouldn't be a bad idea to cut
down on the number of filters supplied out of the box.
I wouldn't be surprised if a number of them are no longer useful
(because ad providers changed their URLs since the filters were
originally created, or because sites changed the way they display
adverts to their users).
Regards,
Robert
On 29/01/07, Lubos Lunak <l.lunak at suse.cz> wrote:
> 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: l.lunak at suse.cz , l.lunak at kde.org
> Lihovarska 1060/12 tel: +420 284 028 972
> 190 00 Prague 9 fax: +420 284 028 951
> Czech Republic http//www.suse.cz
> _______________________________________________
> Kde-optimize mailing list
> Kde-optimize at kde.org
> https://mail.kde.org/mailman/listinfo/kde-optimize
>
More information about the Kde-optimize
mailing list