Hi all, talking with Alexis at akademy, we figured out something realy horrible was happening during the caching of plasma svgs, because when an applet is quickly resized, plasma cpu and disk usage spikes, actually passing all the time compressing images and writing them to the disk. so i looked a bit at it and found this http://websvn.kde.org/trunk/KDE/kdelibs/plasma/framesvg.cpp?r1=970932&r2=975773
this commit made the code cleaner, but totally defies the concept of delayed cache writing, in fact it writes all of the images asked to be inserted into the cache. why is bad? because if an applet is resized, every rendered svg will be inserted into the cache, from start size to end size of the drag resize. all the middle sizes are totally useless in term of the purpose of the cache (they won't be needed in the future) and case a tremendous cpu usage (valgrind, oprofile,whatever will say that 99% of the time is spent inside zlib, compressing the stuff to put into the hard drive, wee :)) the attached patch is an horrid kludge, but kinda fixes the problem it removes from the pixmaps to be inserted all the ones that starts with the same piece of key, so all the ones with the same path, when a new pixmap is inserted. of course this is ugly, but the result is fuckingly faster... now, what could be a proper way to do it (without having to change the api, sigh)? a way could be like now, parsing the key and throwing away other sizes of the same framesvg, or just revert that commit... the issue is kinda urgent, because kde4.3 is affected too, so someting backportable should be quickly found... Cheers, Marco Martin
Index: popupapplet.cpp =================================================================== --- popupapplet.cpp (revision 995762) +++ popupapplet.cpp (working copy) @@ -157,7 +157,7 @@ } QSizeF minimum; - QSizeF containmentSize; + QSizeF parentSize; QGraphicsWidget *gWidget = q->graphicsWidget(); //kDebug() << "graphics widget is" << (QObject*)gWidget; @@ -175,14 +175,13 @@ minimum = qWidget->minimumSizeHint(); } - if (q->containment()) { - containmentSize = q->containment()->size(); + if (q->parentWidget()) { + parentSize = q->parentWidget()->size(); } //Applet on desktop - if (icon && !icon->icon().isNull() && ((f != Plasma::Vertical && f != Plasma::Horizontal) || - ((f == Plasma::Vertical && containmentSize.width() >= minimum.width()) || - (f == Plasma::Horizontal && containmentSize.height() >= minimum.height())))) { + if (icon && !icon->icon().isNull() && ((parentSize.width() >= minimum.width()) && + (parentSize.height() >= minimum.height()))) { //kDebug() << "we are expanding the popupapplet"; // we only switch to expanded if we aren't horiz/vert constrained and Index: theme.cpp =================================================================== --- theme.cpp (revision 995762) +++ theme.cpp (working copy) @@ -696,6 +696,22 @@ void Theme::insertIntoCache(const QString& key, const QPixmap& pix) { if (d->useCache()) { + //FIXME: i know this is EVIL + QHash<QString, QPixmap>::const_iterator it = d->pixmapsToCache.constBegin(); + + QStringList pixmapsToDelete; + QString path = key.split("_").first(); + while (it != d->pixmapsToCache.constEnd()) { + if (path == it.key().split("_").first()) { + pixmapsToDelete.append(it.key()); + } + ++it; + } + + foreach (QString key, pixmapsToDelete) { + d->pixmapsToCache.remove(key); + } + d->pixmapsToCache.insert(key, pix); d->saveTimer->start(500); }
_______________________________________________ Plasma-devel mailing list Plasma-devel@kde.org https://mail.kde.org/mailman/listinfo/plasma-devel