Re: Zend fast cache

From: Date: Sun, 01 Dec 2002 05:20:19 +0000
Subject: Re: Zend fast cache
References: 1 2 3  Groups: php.dev 
Request: Send a blank email to php-dev+get-91972@lists.php.net to get a copy of this message
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

« previous php.dev (#91972) next »