Skip to content

Performance and API improvements for TypeInfo

Stefan Brüns requested to merge bruns/kfilemetadata:cleanup_type into master

This MR applies a number of changes previously done for PropertyInfo to TypeInfo. Both classes work in a very similar way, and have very similar APIs.

All changes are ABI and API compatible (only one new API method), and thus can also be trivially applied to KF5.

A new method, TypeInfo::allNames() is added, which allows to retrieve all known types. This mirrors the recently added PropertyInfo::allNames() method.

The performance improvements are due to removing most allocation from runtime (the types are immutable, and thus all data can be shared globally), and due to removing the localization calls from the constructor, delaying it until it is actually required.

To verify the changes, both unit test and benchmarks are added.

Benchmark results (Release build, x86_64 Tigerlake CPU)

time [usecs] per iteration
        archive   spreadsheet     folder
   -- benchmarkTypeInfo --
old:      0.381         0.380      0.370
new:      0.006         0.007      0.008
   -- benchmarkTypeInfoFromName --
old:      0.450         2.30       3.40
new:      0.028         0.034      0.029
   -- benchmarkTypeInfoDisplayName --
old:      0.390         0.385      0.370
new:      0.350         0.360      0.350

As can be seen, many cases improve by 50..100 times (SIC!), only TypeInfo::displayName() calls remain slow due to i18n. This should not matter much though, as these calls should be rare (i.e. required once per column, instead of once per cell, when creating a tabular/detailed directory view).

Edited by Stefan Brüns

Merge request reports