Cache system tray applet information
ClosedPublic

Authored by davidedmundson on Sep 12 2016, 8:44 PM.

Details

Summary

Plasma::PluginLoader::self()->listAppletInfo(QString() is expensive, it
loads and parses every .desktop file individually. Twice.

The main offender is the defaultApplets property, which gets requested
multiple times from JS space, and we reparse the files every time.

Moving the work to the constructor solves that. This saves loading (on
my machine) ~900 desktop files.

Test Plan
  • wiped config, defaults appeared
  • DBus activated still worked
  • restore works as before

Running "time plasmashell" shows:

BEFORE:
plasmashell 4.01s user 0.46s system 87% cpu 5.116 total
plasmashell 4.01s user 0.54s system 74% cpu 6.124 total

AFTER:
plasmashell 3.17s user 0.42s system 68% cpu 5.259 total
plasmashell 3.18s user 0.46s system 81% cpu 4.475 total

Diff Detail

Repository
R120 Plasma Workspace
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
davidedmundson retitled this revision from to Cache system tray applet information.
davidedmundson updated this object.
davidedmundson edited the test plan for this revision. (Show Details)
davidedmundson added a reviewer: Plasma.
Restricted Application added a project: Plasma. · View Herald TranscriptSep 12 2016, 8:44 PM
Restricted Application added a subscriber: plasma-devel. · View Herald Transcript
broulik added inline comments.
applets/systemtray/systemtray.cpp
390–393

Don't iterate over values(), you're creating a temporary QList just to iterate over it:

for (auto it = m_systrayApplets.constBegin(); end = m_systrayAppltes.constEnd(); it != end; ++it) {
    const KPluginInfo &info = it.value();
    ...
}

const iterator

mart added a subscriber: mart.Sep 13 2016, 9:02 AM
mart added inline comments.
applets/systemtray/systemtray.cpp
102

maybe better not to put new q_foreach as is going to be deprecated?

mart accepted this revision.Sep 13 2016, 4:56 PM
mart added a reviewer: mart.
This revision is now accepted and ready to land.Sep 13 2016, 4:56 PM
This revision was automatically updated to reflect the committed changes.