Skip to content

Fix preset chooser performance issues (Bug 440951)

Mathias Wein requested to merge mwein/krita:bug_440951 into master

This basically just skips empty strings in KisAllResourcesModel::resourceExists(), so the rest is about my findings and some doubts I have.

Basically, it turned out that searching resources by filename is pretty fast, because the resource table creates an autoindex for it due to the UNIQUE("storage_id","resource_type_id","filename") condition.

Searching for md5 however ends up in a linear search that takes ~30ms here with a bunch of carried over resource packs from 4.x, and that results in quite some freezes when scrolling.

Interestingly, searching for name isn't nearly as slow, although the "EXPLAIN QUERY PLAN" output looks no different, no idea why.

So much for analysis, and the change here is enough to make scrolling smooth again for me, but then I realized these queries don't care about resource type at all, but are used to check brush preset dependencies. A PNG image can be a brush tip or a pattern? But the metadata does not seem to have this information anyway, so I'm not sure if this really works correctly like this.

Test Plan

Try to reproduce Bug 440951, basically. And check for presets unexpectedly (not) marked broken.

Formalities Checklist

  • I confirmed this builds.
  • I confirmed Krita ran and the relevant functions work.
  • I tested the relevant unit tests and can confirm they are not broken. (If not possible, don't hesitate to ask for help!)
  • I made sure my commits build individually and have good descriptions as per KDE guidelines.
  • I made sure my code conforms to the standards set in the HACKING file.
  • I can confirm the code is licensed and attributed appropriately, and that unattributed code is mine, as per KDE Licensing Policy.

Merge request reports