diff options
author | Zeev Suraski <zeev@php.net> | 1999-12-27 19:07:33 +0000 |
---|---|---|
committer | Zeev Suraski <zeev@php.net> | 1999-12-27 19:07:33 +0000 |
commit | b7a5b3c309ad64ddf9d60cfd3ca21d9f25315d87 (patch) | |
tree | c251467f12cd03303f2a1a0f7b3694c7a666f08e /Zend/zend_alloc.c | |
parent | 27daca31f376a323462aeff76bc1b55bab7d8841 (diff) | |
download | php-git-b7a5b3c309ad64ddf9d60cfd3ca21d9f25315d87.tar.gz |
- Generalize the fast cache mechanism
- Add the HashTable struct to the fast cache mechanism
Diffstat (limited to 'Zend/zend_alloc.c')
-rw-r--r-- | Zend/zend_alloc.c | 37 |
1 files changed, 22 insertions, 15 deletions
diff --git a/Zend/zend_alloc.c b/Zend/zend_alloc.c index d778d6fd6c..174305c48e 100644 --- a/Zend/zend_alloc.c +++ b/Zend/zend_alloc.c @@ -23,7 +23,7 @@ #include "zend.h" #include "zend_alloc.h" #include "zend_globals.h" -#include "zend_zval_alloc.h" +#include "zend_fast_cache.h" #ifdef HAVE_SIGNAL_H # include <signal.h> #endif @@ -106,7 +106,6 @@ ZEND_API void *_emalloc(size_t size ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC) zend_mem_header *p; ALS_FETCH(); - if (!ZEND_DISABLE_MEMORY_CACHE && (size < MAX_CACHED_MEMORY) && (AG(cache_count)[size] > 0)) { p = AG(cache)[size][--AG(cache_count)[size]]; #if ZEND_DEBUG @@ -321,7 +320,6 @@ ZEND_API int zend_set_memory_limit(unsigned int memory_limit) ZEND_API void start_memory_manager(ALS_D) { AG(phead) = AG(head) = NULL; - AG(zval_list_head) = NULL; #if MEMORY_LIMIT AG(memory_limit)=1<<30; /* rediculous limit, effectively no limit */ @@ -331,9 +329,10 @@ ZEND_API void start_memory_manager(ALS_D) #if ZEND_DEBUG memset(AG(cache_stats), 0, sizeof(AG(cache_stats))); - memset(AG(zval_cache_stats), 0, sizeof(AG(zval_cache_stats))); + memset(AG(fast_cache_stats), 0, sizeof(AG(fast_cache_stats))); #endif + memset(AG(fast_cache_list_head), 0, sizeof(AG(fast_cache_list_head))); memset(AG(cache_count),0,MAX_CACHED_MEMORY*sizeof(unsigned char)); } @@ -341,19 +340,23 @@ ZEND_API void start_memory_manager(ALS_D) ZEND_API void shutdown_memory_manager(int silent, int clean_cache) { zend_mem_header *p, *t; + int fci; #if ZEND_DEBUG int had_leaks=0; #endif - zend_zval_list_entry *zval_list_entry, *next_zval_list_entry; + zend_fast_cache_list_entry *fast_cache_list_entry, *next_fast_cache_list_entry; ALS_FETCH(); - zval_list_entry = AG(zval_list_head); - while (zval_list_entry) { - next_zval_list_entry = zval_list_entry->next; - efree(zval_list_entry); - zval_list_entry = next_zval_list_entry; + + for (fci=0; fci<MAX_FAST_CACHE_TYPES; fci++) { + fast_cache_list_entry = AG(fast_cache_list_head)[fci]; + while (fast_cache_list_entry) { + next_fast_cache_list_entry = fast_cache_list_entry->next; + efree(fast_cache_list_entry); + fast_cache_list_entry = next_fast_cache_list_entry; + } + AG(fast_cache_list_head)[fci] = NULL; } - AG(zval_list_head) = NULL; p=AG(head); t=AG(head); @@ -409,14 +412,18 @@ ZEND_API void shutdown_memory_manager(int silent, int clean_cache) } fprintf(stderr, "Memory cache statistics\n" "-----------------------\n\n" - "[zval, %2d]\t\t%d / %d (%.2f%%)\n", + "[zval, %2d]\t\t%d / %d (%.2f%%)\n" + "[hash, %2d]\t\t%d / %d (%.2f%%)\n", sizeof(zval), - AG(zval_cache_stats)[1], AG(zval_cache_stats)[0]+AG(zval_cache_stats)[1], - ((double) AG(zval_cache_stats)[1] / (AG(zval_cache_stats)[0]+AG(zval_cache_stats)[1]))*100); + AG(fast_cache_stats)[ZVAL_CACHE_LIST][1], AG(fast_cache_stats)[ZVAL_CACHE_LIST][0]+AG(fast_cache_stats)[ZVAL_CACHE_LIST][1], + ((double) AG(fast_cache_stats)[ZVAL_CACHE_LIST][1] / (AG(fast_cache_stats)[ZVAL_CACHE_LIST][0]+AG(fast_cache_stats)[ZVAL_CACHE_LIST][1]))*100, + sizeof(HashTable), + AG(fast_cache_stats)[HASHTABLE_CACHE_LIST][1], AG(fast_cache_stats)[HASHTABLE_CACHE_LIST][0]+AG(fast_cache_stats)[HASHTABLE_CACHE_LIST][1], + ((double) AG(fast_cache_stats)[HASHTABLE_CACHE_LIST][1] / (AG(fast_cache_stats)[HASHTABLE_CACHE_LIST][0]+AG(fast_cache_stats)[HASHTABLE_CACHE_LIST][1]))*100); for (i=0; i<MAX_CACHED_MEMORY; i+=2) { - fprintf(stderr, "[%2d, %2d]\t\t", i+1, i+2); + fprintf(stderr, "[%2d, %2d]\t\t", i, i+1); for (j=0; j<2; j++) { fprintf(stderr, "%d / %d (%.2f%%)\t\t", AG(cache_stats)[i+j][1], AG(cache_stats)[i+j][0]+AG(cache_stats)[i+j][1], |