Gajim performance enhancements
Problems:
-
Gajim has a slow startup even with warm cache in particular on slower hardware (think netbooks)
-
Advanced Configuration Editor takes too long to open
All patches against svn r10596.
The first 8 patches address the startup time.
Measured time is from startup to complete shutdown on an Intel Celeron M 550@2GHz throttled to 25%, which is faster than an Intel Atom 270@800MHz (best of 5 runs):
svn: 150124 function calls (144700 primitive calls) in 4.327 CPU seconds
01: 149543 function calls (144076 primitive calls) in 4.210 CPU seconds
02: 85474 function calls ( 81517 primitive calls) in 3.493 CPU seconds
03: 70477 function calls ( 67289 primitive calls) in 3.303 CPU seconds
04: 70469 function calls ( 67281 primitive calls) in 3.230 CPU seconds
05: 40612 function calls ( 38603 primitive calls) in 2.914 CPU seconds
06: 39590 function calls ( 37581 primitive calls) in 2.796 CPU seconds
07: 38208 function calls ( 36221 primitive calls) in 2.749 CPU seconds
08: 37394 function calls ( 35407 primitive calls) in 2.649 CPU seconds
09: 33641 function calls ( 31654 primitive calls) in 2.661 CPU seconds
Results:
-38% startup/shutdown time
-78% method calls
In a different patch I could even further reduce the startup time by ~200ms / ~10,000 method calls, by making the options in common/config.py immutable, this avoids deepcopying the whole datastructure and reduces memory usage by ~60 kB (on x86_64), too.
Patch 9 adresses an issue, where the config gets saved two times on shutdown to disk. I removed one call and hope this is the right solution here.
Patch 10 uses the buffering of expat, so that the cdata callback does not get called for every line in the parsed data. This reduced the callbacks on a sample login from ~4,000 to a few hundred if I remember correctly.
Patch 11 leads to a huge performance increase in the advancedconfigurationwindow (time to open):
09: 127324 function calls in 2.842 CPU seconds
10: 4109 function calls (3982 primitive calls) in 0.342 CPU seconds
Results:
-88% open time
-97% method calls
Even an Intel Atom@800MHz opens the Window almost instantly now.
The problems I have found:
-
Adding items to the treestore after the filter was added caused refiltering (minor issue)
-
Searching the model for the parent iter for every added item made the algorithm N squared. It took ~35,000 method calls to add ~550 items (major issue). Treestores have persistent iters so this is not necessary.
I added a method, which makes the config appear as a tree, but maybe the config should be a tree.