Plasma uses a lot of files from disk, particularly when using QML and scripted Plasmoids, but also whenever something requests an image from the theme. The Package class is responsible for the former functionality and the Theme class for the latter. We already cache the results of the Theme rendering, but not the results of looking around on disk for the requested image. There is essentially no caching at all for Package: every request for a file sends it looking on disk for it.
The impact of this is relatively low thanks to caching by the operating system, but it isn't negligable. When we start thinking of smaller devices it becomes even less negligable. So while working on libplasma2 I decided something needed to be done.
This past week I started a refactoring of the Package classes so that less memory was used, both by using a smaller data structure on devices and by using an implicitly shared pointer for the private data (which improves things on all targets, including the desktop). PackageStructure went from being a data bearing class to a mutator of Package, which allows them to be properly shared between Package objects. I then added a lookup cache to Package.
The result was that the copy test (100k copies and deletions) went from ~2700ms to ~37ms, while 100k copies, file lookups and deletions went from ~3900ms to ~40ms. All while the memory footprint shrunk. Unfortunately, this isn't really backportable to libplasma1 as the changes that were required to achieve this were significant. These changes were on top of previous changes made in the refactoring of Package and PackageStructure which drew the data "closer" to Package and cut out a lot of collection creation and copying. So reasonably good wins there.
Theme also got a lookup cache, and the good news is that this is backportable and has, in fact, been cherry picked into both the 4.7 and master (will be 4.8) branches. There the results were striking as well: 100k lookups of 3 different files in the theme dropped from a little over 6 seconds to ~1/4th of a second. That's an order of magnitude improvement. Unlike with Package, overall this will end up taking a little more memory, but we're talking about a few kilobytes at most which isn't particularly significant compared to the time savings. Since Theme is used heavily and the same SVGs are asked for over and over again during a Plasma applications execution, this should have some very nice impacts at runtime.
I still haven't done the screencasts and snapshots I need to for my Share Like Connect blog entry, but I was busy today finishing this stuff up ... and attending telco or two, and doing presentation prep for next month and dealing with the construction people who put in the new decking today... so the usual distractions. :)