Cache the default KColorScheme configuration

Authored by mwolff on Jan 30 2019, 8:41 AM.

Description

Cache the default KColorScheme configuration

Summary:
KDevelop, Kate and probably other applications too, recreate
KColorScheme instances repeatedly. This was very costly when an
explicit color scheme was set on the application, since we ended
up reparsing the internal color scheme configuration file every
time - the shared configuration wasn't stored anywhere thus its
refcount dropped to zero once the KColorScheme was fully constructed.

Optimize this apparently common scenario by caching the configuration
in a thread_local variable and only open a new configuration when the
user changed the application color scheme.

Benchmark results before:

RESULT : KColorSchemeTest::benchConstruction():"default":

0.076 msecs per iteration (total: 78, iterations: 1024)

RESULT : KColorSchemeTest::benchConstruction():"explicit":

0.85 msecs per iteration (total: 55, iterations: 64)

Benchmark results after:

RESULT : KColorSchemeTest::benchConstruction():"default":

0.076 msecs per iteration (total: 78, iterations: 1024)

RESULT : KColorSchemeTest::benchConstruction():"explicit":

0.077 msecs per iteration (total: 79, iterations: 1024)

Reviewers: Kate, KDevelop, dfaure, broulik

Subscribers: kde-frameworks-devel

Tags: Frameworks

Differential Revision: https://phabricator.kde.org/D18612

Details