JS speed - Konq vs. Mozilla
Koos Vriezen
koos.vriezen at xs4all.nl
Wed Sep 18 22:07:13 BST 2002
Hi,
Second version of new memory allocation for kjs. Changes:
- moved CollectorBlock::free to BlockIterator::freeCurrent, which makes
the BlockIterator less hacky
- some comments added
- removed the Collector::timesFilled wierdness
The attached header diff fits both others.
The last attachments removes Collector::timesFilled from current CVS,
which basicly prevents the garbage collector to collect garbage after a
while. Anyone objects applying this one?
Koos
-------------- next part --------------
A non-text attachment was scrubbed...
Name: collector.cpp.gz
Type: application/x-gunzip
Size: 3958 bytes
Desc:
URL: <https://mail.kde.org/mailman/private/kfm-devel/attachments/20020918/5e41a69c/attachment.bin>
-------------- next part --------------
Index: collector.h
===================================================================
RCS file: /home/kde/kdelibs/kjs/collector.h,v
retrieving revision 1.16
diff -u -3 -p -r1.16 collector.h
--- collector.h 2002/06/19 08:20:59 1.16
+++ collector.h 2002/09/18 20:47:27
@@ -94,10 +94,9 @@ namespace KJS {
static CollectorBlock* currentBlock;
static unsigned long filled;
static unsigned long softLimit;
- static unsigned long timesFilled;
- static unsigned long increaseLimitAt;
+ static unsigned long alignment;
static bool memLimitReached;
- enum { BlockSize = 100 };
+ enum { BlockSize = 7600 };
};
};
-------------- 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/18 20:55:05
@@ -66,9 +66,6 @@ CollectorBlock* Collector::currentBlock
unsigned long Collector::filled = 0;
unsigned long Collector::softLimit = KJS_MEM_INCREMENT;
-unsigned long Collector::timesFilled = 0;
-unsigned long Collector::increaseLimitAt = 1;
-
bool Collector::memLimitReached = false;
#ifdef KJS_DEBUG_MEM
@@ -84,20 +81,11 @@ void* Collector::allocate(size_t s)
// should only require small amounts of memory, but for complex scripts we don't
// want to end up running the garbage collector hundreds of times a second.
if (filled >= softLimit) {
- timesFilled++;
collect();
-
- if (filled >= softLimit && softLimit < KJS_MEM_LIMIT) {
- // Even after collection we are still using more than the limit, so increase
- // the limit
- softLimit *= 2;
- }
- else if (timesFilled == increaseLimitAt && increaseLimitAt < 128) {
- // The allowed memory limit keeps getting reached (lots of objects created
- // and deleted). Increase it a bit so GC gets run less often.
- timesFilled = 0;
- softLimit *= 2;
- increaseLimitAt *= 2;
+ if (softLimit/(1+filled) < 2 && softLimit < KJS_MEM_LIMIT) {
+ // Even after collection we are still using more than half of the limit,
+ // so increase the limit
+ softLimit = (unsigned long) (softLimit * 1.4);
}
}
More information about the kfm-devel
mailing list