1
0
Fork 0

remove type/cache/hvalue from cached copy to reduce memory usage a little bit

git-svn-id: svn://svn.lighttpd.net/xcache/trunk@854 c26eb9a1-5813-0410-bd6c-c2e55f420ca7
This commit is contained in:
Xuefer 2012-03-28 08:48:20 +00:00
parent c92727b809
commit 64de704dbf
4 changed files with 251 additions and 297 deletions

View File

@ -388,14 +388,14 @@ static int xc_check_names(const char *file, int line, const char *functionName,
/* }}} */
dnl ================ export API
define(`DEFINE_STORE_API', `
/* export: $1 *xc_processor_store_$1($1 *src TSRMLS_DC); :export {{{ */
$1 *xc_processor_store_$1($1 *src TSRMLS_DC) {
/* export: $1 *xc_processor_store_$1(xc_cache_t *cache, $1 *src TSRMLS_DC); :export {{{ */
$1 *xc_processor_store_$1(xc_cache_t *cache, $1 *src TSRMLS_DC) {
$1 *dst;
xc_processor_t processor;
memset(&processor, 0, sizeof(processor));
processor.reference = 1;
processor.cache = src->ifelse(`$1', `xc_entry_php_t', entry.)cache;
processor.cache = cache;
IFASSERT(`xc_stack_init(&processor.allocsizes);')
@ -417,7 +417,7 @@ $1 *xc_processor_store_$1($1 *src TSRMLS_DC) {
}
src->ifelse(`$1', `xc_entry_php_t', entry.)size = processor.size;
ifelse(
`$1', `xc_entry_t', `src->data.var.have_references = processor.have_references;',
`$1', `xc_entry_var_t', `src->have_references = processor.have_references;',
`$1', `xc_entry_data_php_t', `src->have_references = processor.have_references;'
)

View File

@ -1066,10 +1066,9 @@ DEF_STRUCT_P_FUNC(`xc_entry_data_php_t', , `dnl {{{
processor->php_src = src;
')
PROCESS(xc_hash_value_t, hvalue)
/* skip */
DONE(next)
COPY(cache)
PROCESS(xc_hash_value_t, hvalue)
PROCESS(xc_md5sum_t, md5)
PROCESS(zend_ulong, refcount)
@ -1118,19 +1117,9 @@ DEF_STRUCT_P_FUNC(`xc_entry_data_php_t', , `dnl {{{
PROCESS(zend_bool, have_references)
')
dnl }}}
DEF_STRUCT_P_FUNC(`xc_entry_data_var_t', , `dnl {{{
IFDPRINT(`INDENT()`'fprintf(stderr, "zval:value");')
STRUCT_P_EX(zval_ptr, dst->value, src->value, `value', `', `&')
PROCESS(zend_bool, have_references)
DONE(value)
')
dnl }}}
DEF_STRUCT_P_FUNC(`xc_entry_t', , `dnl {{{
PROCESS(xc_hash_value_t, hvalue)
/* skip */
DONE(next)
COPY(cache)
PROCESS(xc_entry_type_t, type)
PROCESS(size_t, size)
PROCESS(time_t, ctime)
@ -1163,28 +1152,11 @@ DEF_STRUCT_P_FUNC(`xc_entry_t', , `dnl {{{
')
DONE(name)
dnl }}}
dnl {{{ data
DISABLECHECK(`
switch (src->type) {
case XC_TYPE_PHP:
IFCALCCOPY(`COPY(data.php)', `STRUCT_P(xc_entry_data_php_t, data.php)')
break;
case XC_TYPE_VAR:
STRUCT(xc_entry_data_var_t, data.var)
break;
default:
assert(0);
}
')
DONE(data)
dnl }}}
')
dnl }}}
DEF_STRUCT_P_FUNC(`xc_entry_php_t', , `dnl {{{
STRUCT(xc_entry_t, entry)
IFCALCCOPY(`COPY(php)', `STRUCT_P(xc_entry_data_php_t, php)')
IFSTORE(`dst->refcount = 0; DONE(refcount)', `PROCESS(long, refcount)')
PROCESS(time_t, file_mtime)
@ -1193,30 +1165,25 @@ DEF_STRUCT_P_FUNC(`xc_entry_php_t', , `dnl {{{
PROCESS(int, file_inode)
#endif
if (src->entry.type == XC_TYPE_PHP) {
PROCESS(int, filepath_len)
IFRESTORE(`COPY(filepath)', `PROC_STRING_L(filepath, filepath_len)')
PROCESS(int, dirpath_len)
IFRESTORE(`COPY(dirpath)', `PROC_STRING_L(dirpath, dirpath_len)')
PROCESS(int, filepath_len)
IFRESTORE(`COPY(filepath)', `PROC_STRING_L(filepath, filepath_len)')
PROCESS(int, dirpath_len)
IFRESTORE(`COPY(dirpath)', `PROC_STRING_L(dirpath, dirpath_len)')
#ifdef IS_UNICODE
PROCESS(int, ufilepath_len)
IFRESTORE(`COPY(ufilepath)', `PROC_USTRING_L(ufilepath, ufilepath_len)')
PROCESS(int, udirpath_len)
IFRESTORE(`COPY(udirpath)', `PROC_USTRING_L(udirpath, udirpath_len)')
PROCESS(int, ufilepath_len)
IFRESTORE(`COPY(ufilepath)', `PROC_USTRING_L(ufilepath, ufilepath_len)')
PROCESS(int, udirpath_len)
IFRESTORE(`COPY(udirpath)', `PROC_USTRING_L(udirpath, udirpath_len)')
#endif
}
else {
DONE(filepath_len)
DONE(filepath)
DONE(dirpath_len)
DONE(dirpath)
#ifdef IS_UNICODE
DONE(ufilepath_len)
DONE(ufilepath)
DONE(udirpath_len)
DONE(udirpath)
#endif
}
')
dnl }}}
DEF_STRUCT_P_FUNC(`xc_entry_var_t', , `dnl {{{
STRUCT(xc_entry_t, entry)
IFDPRINT(`INDENT()`'fprintf(stderr, "zval:value");')
STRUCT_P_EX(zval_ptr, dst->value, src->value, `value', `', `&')
PROCESS(zend_bool, have_references)
DONE(value)
')
dnl }}}
dnl ====================================================

433
xcache.c

File diff suppressed because it is too large Load Diff

View File

@ -354,7 +354,6 @@ typedef struct {
} xc_autoglobal_t;
/* }}} */
#endif
typedef enum { XC_TYPE_PHP, XC_TYPE_VAR } xc_entry_type_t;
typedef struct {
char digest[16];
} xc_md5sum_t;
@ -368,9 +367,8 @@ typedef struct {
/* }}} */
/* {{{ xc_entry_data_php_t */
struct _xc_entry_data_php_t {
xc_hash_value_t hvalue;
xc_entry_data_php_t *next;
xc_cache_t *cache;
xc_hash_value_t hvalue;
xc_md5sum_t md5; /* md5sum of the source */
zend_ulong refcount; /* count of entries referencing to this data */
@ -409,23 +407,12 @@ struct _xc_entry_data_php_t {
zend_bool have_references;
};
/* }}} */
/* {{{ xc_entry_data_var_t */
typedef struct {
zval *value;
zend_bool have_references;
} xc_entry_data_var_t;
/* }}} */
typedef zvalue_value xc_entry_name_t;
/* {{{ xc_entry_t */
struct _xc_entry_t {
xc_hash_value_t hvalue;
xc_entry_t *next;
xc_cache_t *cache;
xc_entry_type_t type;
size_t size;
xc_entry_t *next;
size_t size;
time_t ctime; /* creation ctime of this entry */
time_t atime; /* access atime of this entry */
time_t dtime; /* deletion time of this entry */
@ -436,15 +423,11 @@ struct _xc_entry_t {
zend_uchar name_type;
#endif
xc_entry_name_t name;
union {
xc_entry_data_php_t *php;
xc_entry_data_var_t var;
} data;
};
typedef struct {
xc_entry_t entry;
xc_entry_data_php_t *php;
zend_ulong refcount; /* count of php instances holding this entry */
time_t file_mtime;
@ -465,6 +448,17 @@ typedef struct {
#endif
} xc_entry_php_t;
/* }}} */
typedef struct {
xc_entry_t entry;
zval *value;
zend_bool have_references;
} xc_entry_var_t;
/* }}} */
typedef struct xc_entry_hash_t { /* {{{ */
xc_hash_value_t cacheslotid;
xc_hash_value_t entryslotid;
} xc_entry_hash_t;
/* }}} */
extern zend_module_entry xcache_module_entry;
#define phpext_xcache_ptr &xcache_module_entry