Hi Dmitry,

No, there's always more work going on (with --enable-memory-limit) with
every emalloc() call to update the size even when real_size isn't updated,
right?  Meaning

 heap->size += true_size;
 if (heap->peak < heap->size) {
    heap->peak = heap->size;
 }

at the end of _zend_mm_alloc_int(), etc.  memory_get_usage() changes after
adding a variable, for example, so I think there's updating even < 128
bytes -- isn't a variable around 56 bytes?  sizeof(zval) + sizeof(Bucket)?
That actually uses 2 small emalloc() calls...

I'm just trying to show that there wouldn't be a performance hit if the
memory usage functions are always enabled...  My comparison was worst case,
I think, since even if the usage functions are always available, some of the
stuff can still be in #if MEMORY_LIMIT (checking against limit, etc.).

I'm saying there appears to be no real penalty for *always* keeping track of
mem usage (for memory_get_[peak_]usage()).  You know that in my tests, one
was compiled with --enable-memory-limit, and the other wasn't (verified by
checking if memory_get_usage() was available).


Thanks,
Matt


----- Original Message -----
From: "Dmitry Stogov"
Sent: Friday, July 28, 2006


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.

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

Reply via email to