SS>>     Common referred to real applications, not 'make test'.

Do you have some data about real applications in PHP that use strings 
longer than 80 bytes via smart strings? My tests show most of the strings 
used are small. Looking at the clients of this functions and taking into 
account that prontf's are usually small and long printf are usually or 
rewritten into heredocs (which don't use smart strings) or separated into 
different functions. 
BTW, why do you think "make test" is a bad test of memory allocation 
patterns? What do you propose as a better test?

SS>>     In fact, whenever strings are not allocated through the
SS>>     engine, 80 bytes is a really poor choice, because the malloc
SS>>     implementation will very likely allocate a 128 byte chunk
SS>>     anyway.

That's very bad news, because actually my test show that about 95% of 
mallocs are for sizes below 100 bytes. But I hope the system malloc has 
some mechanism to deal with it, otherwise we are wasting a real lot of 
memory. Actually, given that tests show 90% of mallocs are for sizes below 
64 bytes, if what you say is right, PHP's memory footprint is at least 
twice as big as it is meant to be. 

The number 80 was chosen because even if malloc allocates 128 bytes, these 
128 bytes would be reused using the Zend memory cache. However, if the 
size of the segment does not allow it to be into the Zend memory cache, 
new malloc would be attempted each time. That was the primery rationale 
for the change, not the memory-saving argument, though it is important 
too.

BTW, the number 128 in the code allocated in fact at least 148 bytes, and 
I don't know what malloc implemetation would do of this. 
-- 
Stanislav Malyshev, Zend Products Engineer   
[EMAIL PROTECTED]  http://www.zend.com/ +972-3-6139665 ext.109



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

Reply via email to