Re: bring speed back into KConfig
Jakub Stachowski <[email protected]> Tue, 15 Apr 2008 21:51:01 +0200
| Newsgroups | gmane.comp.kde.devel.optimize |
|---|---|
| Message-ID | <[email protected]> |
--Boundary-00=_mcQBIRkSMLob4oW Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Dnia wtorek, 15 kwietnia 2008, Dirk Mueller napisa=C5=82: > Hi, > > the "knotify4 eats cpu" bugreport seems to be highly popular, so the reas= on > for that seems to be the incredible performance loss in KConfigIni due to > the "kconfig refactoring branch" being merged last autumn by Andreas > Pakulat. > > The code now uses highlevel QByteArray operations=20 Lots of reallocations and memory copies instead of simple moving of pointer. > and even worse QFile=20 > operations for operating on the .ini files. My testcase of kwin.notifyrc, > this means: Attached very simple patch cuts parsing time by ~50% (on hot cache). It rea= ds=20 whole config file in one go, like KDE3 did. KDE3 also was able to mmap() file instead of reading it, but readAll() show= s=20 5% on profile (using google perftools) so there are still many bigger=20 targets. > > 2000 lines of config > > resulting in > > 16000 ~QByteArray() and 16000 QByteArray() constructions > 6000 syscalls (stat() and 2x llseek()) due to QFile::readLine and > QFile::atEof() > 8000 memcpy operations > > in time: > > 150ms KConfig4 > 45ms via QSettings of Qt 4.4 > 29ms via KConfig3 > > I think thats a bit under performing. Anyone interested in fixing the hot > spots in that code? I think it is fairly obvious why the code is extremely > slow. I wanted to take a look at it myself but I guess I'll run out of ti= me > before I get anywhere. > > Thanks, > Dirk > _______________________________________________ > Kde-optimize mailing list > [email protected] > https://mail.kde.org/mailman/listinfo/kde-optimize --Boundary-00=_mcQBIRkSMLob4oW Content-Type: text/x-diff; charset="iso-8859-1"; name="kconfig-readall.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="kconfig-readall.patch" Index: kconfigini.cpp =================================================================== --- kconfigini.cpp (wersja 797091) +++ kconfigini.cpp (kopia robocza) @@ -89,8 +89,9 @@ bool groupSkip = false; int lineNo=0; - while (!file.atEnd()) { - QByteArray line = file.readLine().trimmed(); + QList<QByteArray> lines=file.readAll().split('\n'); + Q_FOREACH(QByteArray line, lines) { + line=line.trimmed(); lineNo++; // skip empty lines and lines beginning with '#' --Boundary-00=_mcQBIRkSMLob4oW Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Kde-optimize mailing list [email protected] https://mail.kde.org/mailman/listinfo/kde-optimize --Boundary-00=_mcQBIRkSMLob4oW--