Hi Matt,

In case of small size (size <= 128B), your code fit into special case, those
handled by allocator's cache.
The memory_usage information isn't updated in this case.

128B  < size < 256KB - uses zend memeory manager and updates memory_usage
information.
Seems it works with the same speed.

size >= 256KB - utilizes system storage manager (malloc/mmap/...) and checks
memory limit.

Dmitry.


> -----Original Message-----
> From: Matt W [mailto:[EMAIL PROTECTED] 
> Sent: Friday, July 28, 2006 1:43 PM
> To: internals@lists.php.net; Dmitry Stogov; Andi Gutmans
> Subject: Re: [PHP-DEV] memory_get_usage with new Memory Manager
> 
> 
> Hi all,
> 
> For my own curiosity regarding the overhead with memory-limit 
> or keeping track of usage so memory_get_[peak_]usage() can 
> always be enabled, I just did some quick testing.  Using this code
> 
> PHP_FUNCTION(emalloc_tester)
> {
>     int i;
>     long mem_size;
>     void *ptr;
> 
>     if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", 
> &mem_size) ==
> FAILURE) {
>         return;
>     }
> 
>     for (i = 0; i < 100000; i++) {
>         ptr = emalloc(mem_size);
>         efree(ptr);
>     }
> }
> 
> with different mem_size's and timing it.  Using the latest 
> CVS files for 5.2; only difference is the 
> --enable-memory-limit option.  Dual 930MHz PIII Windows 2000 
> system (yes, *both* CPUs were maxed after mem_size got larger 
> than would fit into a block :-)).
> 
>           -ms-
> Size   On     Off
> ------------------
> 8      10.6   10.8
> 32     10.7   10.8
> 128    10.6   10.8
> 512    16.2   16.5
> 1k     16.3   16.5
> 8k     16.3   16.6
> 64k    16.3   16.6
> 128k   16.3   16.6
> 256k   2155   2140
> 512k   2225   2210
> 
> Interesting that it was consistently faster for me *with* 
> memory-limit at the smaller sizes, which I assume are by far 
> the most-used.  Does this help at all? :-)
> 
> 
> Matt
> 
> 

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

Reply via email to