[Laszlo-checkins] r14387 - openlaszlo/trunk/WEB-INF/lps/lfc/kernel/swf9

bargull@openlaszlo.org bargull at openlaszlo.org
Sat Jul 25 17:48:04 PDT 2009


Author: bargull
Date: 2009-07-25 17:48:01 -0700 (Sat, 25 Jul 2009)
New Revision: 14387

Modified:
   openlaszlo/trunk/WEB-INF/lps/lfc/kernel/swf9/LzXMLTranslator.as
Log:
Change 20090725-bargull-Goy by bargull at dell--p4--2-53 on 2009-07-25 17:28:53
    in /home/Admin/src/svn/openlaszlo/trunk
    for http://svn.openlaszlo.org/openlaszlo/trunk

Summary: improve performance for XMLTranslator in swf9

New Features:

Bugs Fixed: LPP-8350 (Large datasets don't load in OL4.4 SWF9/SWF8)

Technical Reviewer: hqm
QA Reviewer: (pending)
Doc Reviewer: (pending)

Documentation:

Release Notes:

Details:
Using the testcase attached at the bug-report for LPP-8350, I've found out that Flash's E4X implementation has got major performance issues when using XML#children() and XML#childIndex(). So the nextSibling() function defined in LzXMLTranslator made the translation process from native-xml to lxz-xml really slow. To workaround these performance issues, the node, its index-position and the children are stored for each node while traversing the dom-tree. This avoids calling the E4X functions multiple times and gives significant performance improvements (e.g. load-time for "testfile6000.xml" from the bugreport was about 50 seconds, with the patch applied the load-time went down to 5 seconds).
    

Tests:
see bugreport
alldata and smokecheck passes in swf9



Modified: openlaszlo/trunk/WEB-INF/lps/lfc/kernel/swf9/LzXMLTranslator.as
===================================================================
--- openlaszlo/trunk/WEB-INF/lps/lfc/kernel/swf9/LzXMLTranslator.as	2009-07-25 15:57:32 UTC (rev 14386)
+++ openlaszlo/trunk/WEB-INF/lps/lfc/kernel/swf9/LzXMLTranslator.as	2009-07-26 00:48:01 UTC (rev 14387)
@@ -106,8 +106,16 @@
         if (! firstChild(xmlnode)) {
             return document.appendChild(copyFlashNode(xmlnode, trimwhitespace, nsprefix));
         }
+        // @devnote Flash's E4X implementation has got major performance issues
+        // when using children() and childIndex(), so we cannot use the nextSibling()
+        // function defined in this class. As a workaround we memorize the children()
+        // XMLList and index-position for each node. (LPP-8350)
+        var stack:Array = [];
+        var last:int = -1;
         var lfcparent:LzDataElement = document;
         var next:XML, node:XML = xmlnode;
+        var children:XMLList = node.children();
+        var idx:int = 0;
         // traverse DOM tree
         for (;;) {
             var kind:String = node.nodeKind();
@@ -125,17 +133,29 @@
                 lfcnode.__LZo = (lfcparent.childNodes.push(lfcnode) - 1);
 
                 // traverse down first
-                if ((next = firstChild(node))) {
+                // if ((next = firstChild(node))) {
+                if ((next = children[0])) {
+                    // save current node, index-position and its children
+                    // @devnote need explicit cast because of flash-bug ASC-2904
+                    stack[int(++last)] = node;
+                    stack[int(++last)] = idx;
+                    stack[int(++last)] = children;
                     // this node is the new context
                     lfcparent = lfcnode;
                     node = next;
+                    children = next.children();
+                    idx = 0;
                     continue;
                 }
             }
             // select next node
-            while (! (next = nextSibling(node))) {
+            // while (! (next = nextSibling(node))) {
+            while (! (next = stack[last][++idx])) {
                 // no nextSibling, go back in DOM
-                node = node.parent();
+                // node = node.parent();
+                children = stack[last--];
+                idx = stack[last--];
+                node = stack[last--];
                 lfcparent = lfcparent.parentNode;
                 if (node === xmlnode) {
                     // reached top element, copy finished
@@ -143,6 +163,7 @@
                 }
             }
             node = next;
+            children = next.children();
         }
         // add return to make flash compiler happy
         return null;



More information about the Laszlo-checkins mailing list