At 02:59 PM 11/30/2002 -0500, Sterling Hughes wrote:
Hey,

I was checking the CVS logs, and I read ::

revision 1.13
date: 2001/11/26 17:27:59;  author: andi;  state: Exp;  lines: +1 -1
- Turn off fast cache until we make sure it performs well.
- The best solution is probably to limit its size.

I was just wondering what was wrong, and what it would take to
get this thing up and running... Thies and I were looking at a
little hack, similiar in nature to this, with preallocating a pool of
zval's, and it yielded a 5% performance increase (all hacking credit
goes to thies btw :).
First of all, let me just say that I wouldn't be too excited about 5% performance difference either way. I already told Thies that from my experience 5% is within the error margin and can change according to compile flags, platform and so on.
The reason why the fast cache didn't work well was because it created quite a bit of memory fragmentation which killed MT servers and also made PHP take up too much memory.

If we preallocated some basic, often used types, i think we'd get a
nice performance increase, perhaps even if we initialized in sapi
modes a few structures in MINIT, we could reuse those instead of
creating and destroying which is currently quite expensive?
That said, I do think that if we can get very fast code to pre-allocate zval's it would be a good idea (hopefully we could get more than 5% increase).
I already have an idea for how I would want such an API to look like and I was planning to write it. It would also be useful for Zend objects which are preallocated today but if a realloc() were to be reached it would take quite some time (although one or two realloc()'s wouldn't be terrible).
My idea is a two dimensional array. We'd allocate 2^n of memory blocks and assign it to array[0]. Once these are full we'd allocate another 2^n memory blocks and realloc() array to size of 2 and make array[1] point to it. The index to a block would be X and to find the right position it'd be array[X/2^n][X%2^n] of course as the length of each array is a power of two we wouldn't actually need to use division and modulo so it'd be fast.
As we don't have templates in C we might be able to put all of this inline in a header file and with macros create such a fast allocating pool for some of the most used types specifically I think it'd be useful for zval's, objects and possible hash tables. I wouldn't overdo the amount of types I'd add to this pool because unless they are allocated and freed extremely often we wouldn't notice a speed difference.

But remember what I said about 5% :)
Andi


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

Reply via email to