Mimetype optimization

Jakub Stachowski stachowski at hypair.net
Tue Apr 22 23:41:53 CEST 2008


Dnia wtorek, 22 kwietnia 2008, Jakub Stachowski napisał:
> Dnia wtorek, 22 kwietnia 2008, David Faure napisał:
> > On Tuesday 22 April 2008, Jakub Stachowski wrote:
> > > Hello,
> > >
> > > profiling dolphin while opening /usr/bin shows that about 35% of time
> > > is spent in QRegExp matching called by kmimefactory.cpp: matchFileName.
> > > This function already contains optimizations: for some simple (but
> > > popular) patterns like *.something or something* it uses direct
> > > comparision instead of QRegExp big gun. It looks like:
> > >    if (pattern like *.something && filename long enough to match the
> > > pattern) compare directly;.
> > > However for short names (lots of them in /usr/bin) it often falls back
> > > to slow path. Attached patch changes is to:
> > > if (pattern like *.something) {
> > > 	if (filename not long enough to match) return false;
> > > 	else compare directly;
> > > }
> > >
> > > and detects patterns without wildcards (is checking for *,? and ]
> > > enough?)
> > >
> > > Results (measured by callgrind):
> > > Unpatched, for 179 calls to KMimeTypeFactory::findFromFileName
> > > - 5554 calls to QRegExp::exactMatch, which accounts for 35% of CPU time
> > >
> > > Patched,  for 150 calls to KMimeTypeFactory::findFromFileName
> > > - QRegExp matched 13 times.  findFromFileName takes 0.67% of CPU time
> >
> > Wow, excellent. Great find.
> > If the kdecore/tests/kmimetypetest unit test still passes, please commit
> > :)
>
> Actually I get two failures (at lines 297 and 619, both related to *.doc)
> with and without the patch. But nothing changed, so I'm commiting.
>
> _______________________________________________
> Kde-optimize mailing list
> Kde-optimize at kde.org
> https://mail.kde.org/mailman/listinfo/kde-optimize

0.22 from open suse 10.3


More information about the Kde-optimize mailing list