andi Thu Jul 15 18:59:54 2004 EDT
Modified files:
/ZendEngine2 zend_alloc.c zend_alloc.h
Log:
- Improve performance of zend_alloc by stopping the size from being a bit
- field.
http://cvs.php.net/diff.php/ZendEngine2/zend_alloc.c?r1=1.137&r2=1.138&ty=u
Index: ZendEngine2/zend_alloc.c
diff -u ZendEngine2/zend_alloc.c:1.137 ZendEngine2/zend_alloc.c:1.138
--- ZendEngine2/zend_alloc.c:1.137 Sat Jul 10 03:45:49 2004
+++ ZendEngine2/zend_alloc.c Thu Jul 15 18:59:54 2004
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: zend_alloc.c,v 1.137 2004/07/10 07:45:49 andi Exp $ */
+/* $Id: zend_alloc.c,v 1.138 2004/07/15 22:59:54 andi Exp $ */
#include "zend.h"
#include "zend_alloc.h"
@@ -163,7 +163,6 @@
AG(cache_stats)[CACHE_INDEX][1]++;
memcpy((((char *) p) + sizeof(zend_mem_header) +
MEM_HEADER_PADDING + size), &mem_block_end_magic, sizeof(long));
#endif
- p->cached = 0;
p->size = size;
return (void *)((char *)p + sizeof(zend_mem_header) +
MEM_HEADER_PADDING);
} else {
@@ -196,7 +195,6 @@
HANDLE_UNBLOCK_INTERRUPTIONS();
return (void *)p;
}
- p->cached = 0;
ADD_POINTER_TO_LIST(p);
p->size = size; /* Save real size for correct cache output */
#if ZEND_DEBUG
@@ -270,7 +268,6 @@
#if !ZEND_DISABLE_MEMORY_CACHE
if ((CACHE_INDEX < MAX_CACHED_MEMORY) && (AG(cache_count)[CACHE_INDEX]
< MAX_CACHED_ENTRIES)) {
AG(cache)[CACHE_INDEX][AG(cache_count)[CACHE_INDEX]++] = p;
- p->cached = 1;
#if ZEND_DEBUG
p->magic = MEM_BLOCK_CACHED_MAGIC;
#endif
@@ -530,42 +527,36 @@
p = AG(head);
t = AG(head);
while (t) {
- if (!t->cached) {
#if ZEND_DEBUG
- if (!t->reported) {
- zend_mem_header *iterator;
- int total_leak=0, total_leak_count=0;
-
- grand_total_leaks++;
- if (!silent) {
-
zend_message_dispatcher(ZMSG_MEMORY_LEAK_DETECTED, t);
- }
- t->reported = 1;
- for (iterator=t->pNext; iterator;
iterator=iterator->pNext) {
- if (!iterator->cached
- &&
iterator->filename==t->filename
- && iterator->lineno==t->lineno)
{
- total_leak += iterator->size;
- total_leak_count++;
- iterator->reported = 1;
- }
- }
- if (!silent && total_leak_count>0) {
-
zend_message_dispatcher(ZMSG_MEMORY_LEAK_REPEATED, (void *) (long)
(total_leak_count));
+ if (!t->reported) {
+ zend_mem_header *iterator;
+ int total_leak=0, total_leak_count=0;
+
+ grand_total_leaks++;
+ if (!silent) {
+
zend_message_dispatcher(ZMSG_MEMORY_LEAK_DETECTED, t);
+ }
+ t->reported = 1;
+ for (iterator=t->pNext; iterator;
iterator=iterator->pNext) {
+ if (iterator->filename==t->filename &&
iterator->lineno==t->lineno) {
+ total_leak += iterator->size;
+ total_leak_count++;
+ iterator->reported = 1;
}
- grand_total_leaks += total_leak_count;
}
+ if (!silent && total_leak_count>0) {
+
zend_message_dispatcher(ZMSG_MEMORY_LEAK_REPEATED, (void *) (long)
(total_leak_count));
+ }
+ grand_total_leaks += total_leak_count;
+ }
#endif
#if MEMORY_LIMIT
- AG(allocated_memory) -= REAL_SIZE(t->size);
+ AG(allocated_memory) -= REAL_SIZE(t->size);
#endif
- p = t->pNext;
- REMOVE_POINTER_FROM_LIST(t);
- ZEND_DO_FREE(t);
- t = p;
- } else {
- t = t->pNext;
- }
+ p = t->pNext;
+ REMOVE_POINTER_FROM_LIST(t);
+ ZEND_DO_FREE(t);
+ t = p;
}
#if ZEND_DEBUG
http://cvs.php.net/diff.php/ZendEngine2/zend_alloc.h?r1=1.52&r2=1.53&ty=u
Index: ZendEngine2/zend_alloc.h
diff -u ZendEngine2/zend_alloc.h:1.52 ZendEngine2/zend_alloc.h:1.53
--- ZendEngine2/zend_alloc.h:1.52 Tue May 25 06:09:46 2004
+++ ZendEngine2/zend_alloc.h Thu Jul 15 18:59:54 2004
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: zend_alloc.h,v 1.52 2004/05/25 10:09:46 andi Exp $ */
+/* $Id: zend_alloc.h,v 1.53 2004/07/15 22:59:54 andi Exp $ */
#ifndef ZEND_ALLOC_H
#define ZEND_ALLOC_H
@@ -50,8 +50,7 @@
struct _zend_mem_header *pNext;
struct _zend_mem_header *pLast;
#endif
- unsigned int size:31;
- unsigned int cached:1;
+ unsigned int size;
} zend_mem_header;
typedef union _align_test {
--
Zend Engine CVS Mailing List (http://cvs.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
|