[Lazarus] Designer speedup, issue #37706, Sven Barth

Juha Manninen juha.manninen62 at gmail.com
Wed Dec 9 01:56:24 CET 2020

Partly inspired by issue
I profiled Lazarus code with Valgrind to find what could cause such a
slowdown in form designer.
I didn't see any serious slowdown myself but clearly the designer eats more
resources than it should.
Registered components were searched all the time by class name. I changed
the cache to use class type instead. It actually simplified and sped up
things. It is function TBaseComponentPalette.FindRegComponent (was
FindComponent) which is called also when mouse moves over the designer.
The biggest change is in r64182.
In r64184 I changed more code to use the component class type cache. By
surprise it caused extreme slowdown. Selecting a component in designer took
> 5 seconds with QT5 bindings, but the CPU was not under load. In addition
with GTK2 bindings the selection dots didn't show.
All that was gone after a clean build!
What could cause it? I have no idea. A Sleep() call or Thread.WaitFor could
cause a delay without CPU load but the code had neither.
Anyway please test with the latest changes. Build clean if you need to.

I want to optimize function TPkgManager.GetUnitsAndDepsForComps.
It is part of Sven Barth's recent addition.
It has 2 nested for-loops. The inner is :
    for CurUnitIdx:=0 to CurUnitNames.Count-1 do
just after an item is added to CurUnitNames. Maybe the loops should go
after each other instead of being nested. Now it may indeed be slow with a
densely populated form.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus-ide.org/pipermail/lazarus/attachments/20201209/167ace8c/attachment.html>

More information about the lazarus mailing list