[Lazarus] [patch] lhelp scrolling slowness - I might have found it

Bernd prof7bit at googlemail.com
Sat Dec 24 20:55:12 CET 2011


The attached patch is only version 1 (don't commit it yet, its not
thoroughly tested and I want to spend some more time and make more
changes until I call it ready for production).

I did some poor-man's profiling with the chm viewer lhelp (hit pause
during the slowness look at the callstack, catch it in the act, repeat
this a few times [effectively the same thing that a sampling profiler
like oprofile would do]). During scrolling of long pages it seemed to
spend a lot (almost all) of its time in the same procedure, looking up
css property names in a TStringList with IndexOf().
TStringList.IndexOf() does a linear search, so I thought why not
replace this with a TFPObjectHashTable. All it has to do is store a
list of objects by name and all it is needed for is looking them up by
name thousands and thousands of times.

After doing this (see the attached patch, its only a few lines) the
scrolling seems a hundred times faster! Really! Try it with rtl.chm
and look up the help for Format(), its a very long page, it was
basically unscrollable before. I'm totally excited! This is the first
time I have seen lhelp being actually usable! This is the reason I
could not wait to post this patch.

I'm now going to see if I can find a few more TStringlists to replace this way.

Bernd
-------------- next part --------------
A non-text attachment was scrubbed...
Name: lhelp_turbopower_ipro_slowness_v1.patch
Type: text/x-diff
Size: 2083 bytes
Desc: not available
URL: <http://lists.lazarus-ide.org/pipermail/lazarus/attachments/20111224/1f3ecdb1/attachment.patch>


More information about the Lazarus mailing list