JS speed - Konq vs. Mozilla

Koos Vriezen koos.vriezen at xs4all.nl
Thu Sep 5 21:31:22 BST 2002


On Wed, 4 Sep 2002, Koos Vriezen wrote:

> I think this will be my final patch for the Collector for now, because
> there is only 5-7% speed to gain here (compared to a allocator that just
> returns 'malloc(size)').

Couldn't resist trying to merge not fully fulled blocks, because it still
can happen (is even likely) that the number of blocks only grows in time.
It also sqeezes another 2% speed gain out of the bench (tested with 0 to
5000).

Regards,

Koos
-------------- next part --------------
Index: collector.cpp
===================================================================
RCS file: /home/kde/kdelibs/kjs/collector.cpp,v
retrieving revision 1.34
diff -u -3 -p -r1.34 collector.cpp
--- collector.cpp	2002/09/05 15:51:38	1.34
+++ collector.cpp	2002/09/05 19:27:55
@@ -213,6 +213,7 @@ bool Collector::collect()
 
   // 2nd step: free memory
   block = root;
+  CollectorBlock *nonfull = 0L;
   while (block) {
     ValueImp **r = block->mem;
     int freespot = block->filled;
@@ -227,6 +228,21 @@ bool Collector::collect()
           firstfreeset = true;
           freespot = r - block->mem;
         }
+      } else if (nonfull) {
+        *(nonfull->mem + nonfull->filled) = imp;
+        nonfull->filled++;
+        filled++;  //compensate for substraction of del
+        del++;
+        while (nonfull && 
+               (nonfull->filled == nonfull->size || nonfull->filled == 0)) {
+          nonfull = nonfull->next;
+          if (nonfull == block)
+            nonfull = 0L;
+        }
+        if (!firstfreeset) {
+          firstfreeset = true;
+          freespot = r - block->mem;
+        }
       } else if (firstfreeset) {
          *(block->mem + freespot) = imp;
          freespot++;
@@ -235,7 +251,16 @@ bool Collector::collect()
     filled -= del;
     block->filled -= del;
     assert(freespot == block->filled);
+    if (!nonfull)
+      nonfull = block;
     block = block->next;
+    while (nonfull && 
+           (nonfull->filled == nonfull->size || nonfull->filled == 0)) {
+      nonfull = nonfull->next;
+      if (nonfull == block)
+        nonfull = 0L;
+    }
+
     if (del)
       deleted = true;
   }


More information about the kfm-devel mailing list