At 07:17 PM 11/30/2002 -0500, Sterling Hughes wrote:
hrm. :)

My only question is really about sequential accesses. for the purpose of example
let's pretend its just for zvals...

(pool is our pool array of zval structs)
ALLOC_ZVAL()
-> Do we have a zval available?
-> yes!
-> return pool[0][0]

ALLOC_ZVAL()
...
-> return pool[0][1]

ALLOC_ZVAL()
...
-> return pool[0][2]

FREE_ZVAL()
-> Clear memory @ pool[0][1]

ALLOC_ZVAL()
-> Do we have a zval available?
-> return pool[0][3] or do we return pool[0][1]

The problem I see with an array approach from an api perspective is simply when a bucket
is free'd, in order to have efficient memory usage, we'd need a second level array scan
for every ALLOC_ZVAL().

Perhaps a linked list would be a better choice for this, as we can just be smart about bucket
access, and eliminate the need for a scan (could be possible I'm missing something?)
I think I was misunderstood. Of course I would want a free list.
Check out the objects_store code in ZE2. The idea is to have something similar. When we free allocated buckets we add them to a linked list. The linked list is inside the structure itself, i.e., when the bucket isn't used we can use its memory for the pointer to the next element. So allocation just takes the bucket out of the free list. So basically the bucket is a union between sizeof(zval) and sizeof(*) (or sizeof(int)).
If it's still not clear I can explain it in a longer letter later on.

Andi


--
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, visit: http://www.php.net/unsub.php



Reply via email to