[Gc] how to mess up malloc?
skaller at users.sourceforge.net
Thu Dec 1 04:57:01 PST 2005
I have just written a rather crude arena allocator.
A dumb test program reveals .. malloc is about 20% faster :)
How fast is malloc? What is a good algorithm to test
the performance differences?
My code just builds a list, and forgets it (more or less).
Every now and then I call the garbage collector: there
are only 3 live objects at this point. In a second
run I use an arena instead, compacting when the arena
is full. The compaction takes 0 time (there are only
3 lives objects).
When using the arena, objects in the arena are not freed,
and allocation just decrements a pointer. Yet malloc is
faster. All the garbage created is one of a small number
of sizes (probably 3 types only are being allocated).
So .. in my test the arena allocator is constant sluggish
time. I'd expect malloc to be worse than constant time,
if it is driven hard enough .. any ideas how to do this?
BTW: I'm using reasonably late GNU C library malloc.
John Skaller <skaller at users dot sf dot net>
Felix, successor to C++: http://felix.sf.net
More information about the Gc