KJS Speedups

KJS Speedups

Best code is written with bad weather outside. This was proven by Maks recent work on KDE’s JavaScript engine at least. While cold and snow were plaguing North America Maks developed some nice and effective optimizations that were merged into trunk last night.

Now what was this about? The easy but slow dynamic variable lookup of KDE 3 is now replaced by a static lookup where the symbol can be bound to a local variable. On the other hand, local variables are skipped if a variable is known not to be part of the set. Due to the dynamic nature of JavaScript this approach cannot be used in all cases but wherever it applies the speedup is very noticeable. Two performance test cases supplied by Richard Moore and the iBench JavaScript test finished in 13% to 39% less time than before. Quite a bit for a single patch!

If one considers the sum of all the latests improvements done by KHTML hackers from and outside of Konqueror will perform significantly better in KDE 4. iBench and Ian Hixie’s JavaScript and DOM performance tests show a speedup factors of 2, 3 and sometimes even higher! This leads to a clear outperforming of Firefox 2.0 in some HTML test cases.

Above results will not apply 1:1 to every page. Some bottlenecks are definitely still left but will be addressed for KDE 4.0 or later releases.