Changeset 1051 in svn


Ignore:
Timestamp:
2012-07-26T05:47:52+02:00 (3 years ago)
Author:
Xuefer
Message:

refactor: move more cache stuffs to mod_cacher

Location:
trunk
Files:
1 added
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/Makefile.frag.deps

    r1046 r1051  
    1 $(XCACHE_INCLUDES_I) $(builddir)/includes.lo: $(srcdir)/xcache.h $(srcdir)/xcache/xc_shm.h $(srcdir)/xcache/xc_mem.h $(srcdir)/xcache/xc_shm.h $(srcdir)/xcache/xc_lock.h $(srcdir)/xcache/xc_compatibility.h
     1$(XCACHE_INCLUDES_I) $(builddir)/includes.lo: $(srcdir)/xcache.h $(srcdir)/xcache/xc_shm.h $(srcdir)/xcache/xc_mem.h $(srcdir)/xcache/xc_shm.h $(srcdir)/xcache/xc_lock.h $(srcdir)/xcache/xc_compatibility.h $(srcdir)/mod_cacher/xc_cache.h $(srcdir)/xcache.h $(srcdir)/xcache/xc_compatibility.h $(srcdir)/xcache/xc_utils.h $(srcdir)/xcache/xc_compatibility.h
    22$(builddir)/mod_assembler/xc_assembler.lo:
    3 $(builddir)/mod_cacher/xc_cacher.lo: $(srcdir)/mod_cacher/xc_cacher.h $(srcdir)/xcache.h $(srcdir)/xcache/xc_shm.h $(srcdir)/xcache/xc_mem.h $(srcdir)/xcache/xc_shm.h $(srcdir)/xcache/xc_lock.h $(srcdir)/xcache/xc_compatibility.h $(XCACHE_PROC_H) $(srcdir)/xcache.h $(srcdir)/xcache_globals.h $(srcdir)/util/xc_stack.h $(srcdir)/xcache/xc_extension.h $(srcdir)/util/xc_stack.h $(srcdir)/xcache/xc_ini.h $(srcdir)/xcache/xc_utils.h $(srcdir)/xcache/xc_compatibility.h $(srcdir)/xcache/xc_sandbox.h $(srcdir)/util/xc_trace.h $(srcdir)/util/xc_vector.h $(srcdir)/util/xc_align.h
     3$(builddir)/mod_cacher/xc_cacher.lo: $(srcdir)/mod_cacher/xc_cacher.h $(srcdir)/mod_cacher/xc_cache.h $(srcdir)/xcache.h $(srcdir)/xcache/xc_shm.h $(srcdir)/xcache/xc_mem.h $(srcdir)/xcache/xc_shm.h $(srcdir)/xcache/xc_lock.h $(srcdir)/xcache/xc_compatibility.h $(srcdir)/xcache/xc_compatibility.h $(XCACHE_PROC_H) $(srcdir)/xcache_globals.h $(srcdir)/util/xc_stack.h $(srcdir)/xcache/xc_extension.h $(srcdir)/util/xc_stack.h $(srcdir)/xcache/xc_ini.h $(srcdir)/xcache/xc_utils.h $(srcdir)/xcache/xc_compatibility.h $(srcdir)/xcache/xc_sandbox.h $(srcdir)/util/xc_trace.h $(srcdir)/util/xc_vector.h $(srcdir)/util/xc_align.h
    44$(builddir)/mod_coverager/xc_coverager.lo: $(srcdir)/mod_coverager/xc_coverager.h $(srcdir)/xcache.h $(srcdir)/xcache/xc_shm.h $(srcdir)/xcache/xc_mem.h $(srcdir)/xcache/xc_shm.h $(srcdir)/xcache/xc_lock.h $(srcdir)/xcache/xc_compatibility.h $(srcdir)/xcache/xc_extension.h $(srcdir)/util/xc_stack.h $(srcdir)/xcache/xc_ini.h $(srcdir)/xcache/xc_utils.h $(srcdir)/xcache/xc_compatibility.h $(srcdir)/util/xc_trace.h $(srcdir)/xcache_globals.h $(srcdir)/util/xc_stack.h
    55$(builddir)/mod_decoder/xc_decoder.lo:
    6 $(builddir)/mod_disassembler/xc_disassembler.lo: $(srcdir)/mod_disassembler/xc_disassembler.h $(srcdir)/xcache.h $(srcdir)/xcache/xc_shm.h $(srcdir)/xcache/xc_mem.h $(srcdir)/xcache/xc_shm.h $(srcdir)/xcache/xc_lock.h $(srcdir)/xcache/xc_compatibility.h $(srcdir)/xcache/xc_ini.h $(srcdir)/xcache/xc_utils.h $(srcdir)/xcache/xc_compatibility.h $(srcdir)/xcache/xc_sandbox.h $(srcdir)/xcache/xc_compatibility.h $(XCACHE_PROC_H) $(srcdir)/xcache.h
     6$(builddir)/mod_disassembler/xc_disassembler.lo: $(srcdir)/mod_disassembler/xc_disassembler.h $(srcdir)/xcache.h $(srcdir)/xcache/xc_shm.h $(srcdir)/xcache/xc_mem.h $(srcdir)/xcache/xc_shm.h $(srcdir)/xcache/xc_lock.h $(srcdir)/xcache/xc_compatibility.h $(srcdir)/xcache/xc_ini.h $(srcdir)/xcache/xc_utils.h $(srcdir)/xcache/xc_compatibility.h $(srcdir)/xcache/xc_sandbox.h $(srcdir)/xcache/xc_compatibility.h $(XCACHE_PROC_H)
    77$(builddir)/mod_encoder/xc_encoder.lo:
    88$(builddir)/mod_optimizer/xc_optimizer.lo: $(srcdir)/mod_optimizer/xc_optimizer.h $(srcdir)/xcache/xc_extension.h $(srcdir)/util/xc_stack.h $(srcdir)/xcache/xc_ini.h $(srcdir)/xcache/xc_utils.h $(srcdir)/xcache.h $(srcdir)/xcache/xc_shm.h $(srcdir)/xcache/xc_mem.h $(srcdir)/xcache/xc_shm.h $(srcdir)/xcache/xc_lock.h $(srcdir)/xcache/xc_compatibility.h $(srcdir)/xcache/xc_compatibility.h $(srcdir)/util/xc_trace.h $(srcdir)/xcache_globals.h $(srcdir)/util/xc_stack.h
  • trunk/includes.c

    r393 r1051  
    11#include "xcache.h"
     2#include "mod_cacher/xc_cache.h"
     3#include "xcache/xc_utils.h"
    24#include "zend_compile.h"
  • trunk/mod_cacher/xc_cacher.c

    r1047 r1051  
    99/* {{{ macros */
    1010#include "xc_cacher.h"
     11#include "xc_cache.h"
    1112#include "xcache.h"
    1213#include "xc_processor.h"
     
    2930#include "SAPI.h"
    3031
     32#define ECALLOC_N(x, n) ((x) = ecalloc(n, sizeof((x)[0])))
     33#define ECALLOC_ONE(x) ECALLOC_N(x, 1)
    3134#define VAR_ENTRY_EXPIRED(pentry) ((pentry)->ttl && XG(request_time) > (pentry)->ctime + (time_t) (pentry)->ttl)
    3235#define CHECK(x, e) do { if ((x) == NULL) { zend_error(E_ERROR, "XCache: " e); goto err; } } while (0)
     
    5457    } \
    5558} while(0)
     59/* }}} */
     60
     61/* {{{ types */
     62struct _xc_hash_t {
     63    size_t bits;
     64    size_t size;
     65    xc_hash_value_t mask;
     66};
    5667/* }}} */
    5768
  • trunk/processor/head.m4

    r1018 r1051  
    1212/* export: #include "xcache.h" :export */
    1313#include "xcache.h"
     14/* export: #include "mod_cacher/xc_cache.h" :export */
     15#include "mod_cacher/xc_cache.h"
    1416#include "util/xc_align.h"
    1517#include "xcache/xc_const_string.h"
     18#include "xcache/xc_utils.h"
    1619#include "xc_processor.h"
    1720#include "xcache_globals.h"
     
    359362            if (!zend_u_hash_exists(done_names, IS_STRING, assert_names[i], strlen(assert_names[i]) + 1)) {
    360363                fprintf(stderr
    361                     , "missing field at %s `#'%d %s`' : %s\n"
     364                    , "Error: missing field at %s `#'%d %s`' : %s\n"
    362365                    , file, line, functionName
    363366                    , assert_names[i]
     
    377380            if (!known) {
    378381                fprintf(stderr
    379                     , "unknown field at %s `#'%d %s`' : %s\n"
     382                    , "Error: unknown field at %s `#'%d %s`' : %s\n"
    380383                    , file, line, functionName
    381384                    , BUCKET_KEY_S(b)
  • trunk/processor/processor.m4

    r1027 r1051  
    10801080')
    10811081IFRESTORE(`', `
    1082 #ifdef E_STRICT
     1082#ifdef XCACHE_ERROR_CACHING
    10831083DEF_STRUCT_P_FUNC(`xc_compilererror_t', , `dnl {{{
    10841084    PROCESS(int, type)
     
    11321132    ')
    11331133#endif
    1134 #ifdef E_STRICT
     1134#ifdef XCACHE_ERROR_CACHING
    11351135    PROCESS(zend_uint, compilererror_cnt)
    11361136    IFRESTORE(`
  • trunk/xcache.h

    r1040 r1051  
    1010#define XCACHE_WIKI_URL   XCACHE_URL "/wiki"
    1111
    12 #include <php.h>
     12#include "php.h"
     13
     14#if defined(E_STRICT) || defined(E_DEPRECATED)
     15#define XCACHE_ERROR_CACHING
     16#endif
    1317
    1418#ifdef HAVE_CONFIG_H
     
    1923#include "xcache/xc_compatibility.h"
    2024
    21 #define ECALLOC_N(x, n) ((x) = ecalloc(n, sizeof((x)[0])))
    22 #define ECALLOC_ONE(x) ECALLOC_N(x, 1)
    23 
    24 typedef ulong xc_hash_value_t;
    25 typedef struct {
    26     size_t bits;
    27     size_t size;
    28     xc_hash_value_t mask;
    29 } xc_hash_t;
    30 
    31 typedef zend_op_array *(zend_compile_file_t)(zend_file_handle *h, int type TSRMLS_DC);
    32 
    33 typedef struct _xc_entry_t xc_entry_t;
    34 typedef struct _xc_entry_data_php_t xc_entry_data_php_t;
    35 /* {{{ xc_cache_t */
    36 typedef struct {
    37     int cacheid;
    38     xc_hash_t  *hcache; /* hash to cacheid */
    39 
    40     time_t     compiling;
    41     zend_ulong updates;
    42     zend_ulong hits;
    43     zend_ulong clogs;
    44     zend_ulong ooms;
    45     zend_ulong errors;
    46     xc_lock_t  *lck;
    47     xc_shm_t   *shm; /* which shm contains us */
    48     xc_mem_t   *mem; /* which mem contains us */
    49 
    50     xc_entry_t **entries;
    51     int entries_count;
    52     xc_entry_data_php_t **phps;
    53     int phps_count;
    54     xc_entry_t *deletes;
    55     int deletes_count;
    56     xc_hash_t  *hentry; /* hash settings to entry */
    57     xc_hash_t  *hphp;   /* hash settings to php */
    58 
    59     time_t     last_gc_deletes;
    60     time_t     last_gc_expires;
    61 
    62     time_t     hits_by_hour_cur_time;
    63     zend_uint  hits_by_hour_cur_slot;
    64     zend_ulong hits_by_hour[24];
    65     time_t     hits_by_second_cur_time;
    66     zend_uint  hits_by_second_cur_slot;
    67     zend_ulong hits_by_second[5];
    68 } xc_cache_t;
    69 /* }}} */
    70 /* {{{ xc_op_array_info_detail_t */
    71 typedef struct {
    72     zend_uint index;
    73     zend_uint info;
    74 } xc_op_array_info_detail_t;
    75 /* }}} */
    76 /* {{{ xc_op_array_info_t */
    77 typedef struct {
    78 #ifdef ZEND_ENGINE_2_4
    79     zend_uint literalinfo_cnt;
    80     xc_op_array_info_detail_t *literalinfos;
    81 #else
    82     zend_uint oplineinfo_cnt;
    83     xc_op_array_info_detail_t *oplineinfos;
    84 #endif
    85 } xc_op_array_info_t;
    86 /* }}} */
    87 /* {{{ xc_classinfo_t */
    88 typedef struct {
    89 #ifdef IS_UNICODE
    90     zend_uchar   type;
    91 #endif
    92     const24_zstr key;
    93     zend_uint    key_size;
    94     ulong        h;
    95     zend_uint  methodinfo_cnt;
    96     xc_op_array_info_t *methodinfos;
    97     xc_cest_t    cest;
    98 #ifndef ZEND_COMPILE_DELAYED_BINDING
    99     int          oplineno;
    100 #endif
    101 } xc_classinfo_t;
    102 /* }}} */
    103 #ifdef HAVE_XCACHE_CONSTANT
    104 /* {{{ xc_constinfo_t */
    105 typedef struct {
    106 #ifdef IS_UNICODE
    107     zend_uchar    type;
    108 #endif
    109     const24_zstr  key;
    110     zend_uint     key_size;
    111     ulong         h;
    112     zend_constant constant;
    113 } xc_constinfo_t;
    114 /* }}} */
    115 #endif
    116 /* {{{ xc_funcinfo_t */
    117 typedef struct {
    118 #ifdef IS_UNICODE
    119     zend_uchar     type;
    120 #endif
    121     const24_zstr   key;
    122     zend_uint      key_size;
    123     ulong          h;
    124     xc_op_array_info_t op_array_info;
    125     zend_function func;
    126 } xc_funcinfo_t;
    127 /* }}} */
    128 #ifdef ZEND_ENGINE_2_1
    129 /* {{{ xc_autoglobal_t */
    130 typedef struct {
    131 #ifdef IS_UNICODE
    132     zend_uchar   type;
    133 #endif
    134     const24_zstr key;
    135     zend_uint    key_len;
    136     ulong        h;
    137 } xc_autoglobal_t;
    138 /* }}} */
    139 #endif
    140 typedef struct {
    141     char digest[16];
    142 } xc_md5sum_t;
    143 /* {{{ xc_compilererror_t */
    144 typedef struct {
    145     int type;
    146     uint lineno;
    147     int error_len;
    148     char *error;
    149 } xc_compilererror_t;
    150 /* }}} */
    151 /* {{{ xc_entry_data_php_t */
    152 struct _xc_entry_data_php_t {
    153     xc_entry_data_php_t *next;
    154     xc_hash_value_t      hvalue;
    155 
    156     xc_md5sum_t md5;        /* md5sum of the source */
    157     zend_ulong  refcount;   /* count of entries referencing to this data */
    158 
    159     zend_ulong hits;        /* hits of this php */
    160     size_t     size;
    161 
    162     xc_op_array_info_t op_array_info;
    163     zend_op_array *op_array;
    164 
    165 #ifdef HAVE_XCACHE_CONSTANT
    166     zend_uint constinfo_cnt;
    167     xc_constinfo_t *constinfos;
    168 #endif
    169 
    170     zend_uint funcinfo_cnt;
    171     xc_funcinfo_t *funcinfos;
    172 
    173     zend_uint classinfo_cnt;
    174     xc_classinfo_t *classinfos;
    175 #ifndef ZEND_COMPILE_DELAYED_BINDING
    176     zend_bool have_early_binding;
    177 #endif
    178 
    179 #ifdef ZEND_ENGINE_2_1
    180     zend_uint autoglobal_cnt;
    181     xc_autoglobal_t *autoglobals;
    182 #endif
    183 
    184 #ifdef E_STRICT
    185     zend_uint compilererror_cnt;
    186     xc_compilererror_t *compilererrors;
    187 #endif
    188 
    189     zend_bool  have_references;
    190 };
    191 /* }}} */
    192 typedef zvalue_value xc_entry_name_t;
    193 /* {{{ xc_entry_t */
    194 struct _xc_entry_t {
    195     xc_entry_t *next;
    196 
    197     size_t     size;
    198     time_t     ctime;           /* creation ctime of this entry */
    199     time_t     atime;           /*   access atime of this entry */
    200     time_t     dtime;           /*  deletion time of this entry */
    201     zend_ulong hits;
    202     zend_ulong ttl;
    203 
    204     xc_entry_name_t name;
    205 };
    206 
    207 typedef struct {
    208     xc_entry_t entry;
    209     xc_entry_data_php_t *php;
    210 
    211     zend_ulong refcount;    /* count of php instances holding this entry */
    212     time_t file_mtime;
    213     size_t file_size;
    214     int file_device;
    215     int file_inode;
    216 
    217     int    filepath_len;
    218     ZEND_24(NOTHING, const) char *filepath;
    219     int    dirpath_len;
    220     char  *dirpath;
    221 #ifdef IS_UNICODE
    222     int    ufilepath_len;
    223     UChar *ufilepath;
    224     int    udirpath_len;
    225     UChar *udirpath;
    226 #endif
    227 } xc_entry_php_t;
    228 
    229 typedef struct {
    230     xc_entry_t entry;
    231 #ifdef IS_UNICODE
    232     zend_uchar name_type;
    233 #endif
    234     zval      *value;
    235     zend_bool  have_references;
    236 } xc_entry_var_t;
    237 /* }}} */
    238 typedef struct xc_entry_hash_t { /* {{{ */
    239     xc_hash_value_t cacheid;
    240     xc_hash_value_t entryslotid;
    241 } xc_entry_hash_t;
    242 /* }}} */
    243 
    24425extern zend_module_entry xcache_module_entry;
    24526#define phpext_xcache_ptr &xcache_module_entry
    246 
    247 int xc_is_rw(const void *p);
    248 int xc_is_ro(const void *p);
    249 int xc_is_shm(const void *p);
    250 /* {{{ xc_gc_op_array_t */
    251 typedef struct {
    252 #ifdef ZEND_ENGINE_2
    253     zend_uint num_args;
    254     zend_arg_info *arg_info;
    255 #endif
    256     zend_op *opcodes;
    257 } xc_gc_op_array_t;
    258 /* }}} */
    259 void xc_gc_add_op_array(xc_gc_op_array_t *gc_op_array TSRMLS_DC);
    260 void xc_fix_op_array_info(const xc_entry_php_t *xce, const xc_entry_data_php_t *php, zend_op_array *op_array, int shallow_copy, const xc_op_array_info_t *op_array_info TSRMLS_DC);
    26127
    26228extern zend_bool xc_test;
  • trunk/xcache/xc_sandbox.h

    r1044 r1051  
    2121zend_uint xc_sandbox_compilererror_cnt(TSRMLS_D);
    2222#ifdef XCACHE_ERROR_CACHING
    23 xc_compilererror_t *xc_sandbox_compilererrors(TSRMLS_D);
     23struct _xc_compilererror_t;
     24struct _xc_compilererror_t *xc_sandbox_compilererrors(TSRMLS_D);
    2425zend_uint xc_sandbox_compilererror_cnt(TSRMLS_D);
    2526#endif
  • trunk/xcache/xc_utils.h

    r1018 r1051  
    22#include "xc_compatibility.h"
    33
    4 typedef struct {
     4typedef zend_op_array *(zend_compile_file_t)(zend_file_handle *h, int type TSRMLS_DC);
     5
     6typedef struct _xc_compilererror_t {
     7    int type;
     8    uint lineno;
     9    int error_len;
     10    char *error;
     11} xc_compilererror_t;
     12
     13typedef struct _xc_compile_result_t {
    514    zend_op_array *op_array;
    615    HashTable *function_table;
     
    3342ZESW(xc_cest_t *, void) xc_install_class(ZEND_24(NOTHING, const) char *filename, xc_cest_t *cest, int oplineno, zend_uchar type, const24_zstr key, uint len, ulong h TSRMLS_DC);
    3443
    35 #if defined(E_STRICT) || defined(E_DEPRECATED)
    36 #define XCACHE_ERROR_CACHING
    37 #endif
    38 
    3944typedef zend_bool (*xc_if_func_t)(void *data);
    4045
Note: See TracChangeset for help on using the changeset viewer.