Changeset 337

Show
Ignore:
Timestamp:
08/20/07 22:57:00 (9 months ago)
Author:
hans
Message:

Added cache object creation timestamp (shm and disk)\nAltered control panel and eaccelerator_cached_scripts() for ttl and creation timestamp display\nChanged some counters in ea_cache_entry from signed to unsigned int\nSome language and mmCache remnants fixed

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • eaccelerator/trunk/ChangeLog

    r333 r337  
    1414          session, shm or user cache functionality (which are all off by 
    1515          default) 
     16        * Added a creation timestamp to each cache object (shm and disk) 
     17        * Added ttl and creation timestamp display to 
     18          eaccelerator_cached_scripts() / control.php 
     19        * Changed some counters in ea_cache_entry from signed to unsigned 
     20          int 
     21        * Renamed some mmCache remnants && fixed typos/language 
    1622 
    17232007-08-20  Bart Vanbrabant <bart.vanbrabant at zoeloelip.be> 
  • eaccelerator/trunk/control.php

    r330 r337  
    474474    <td class="h"><?php echo colheadstr('File', 0)?></td> 
    475475    <td class="h"><?php echo colheadstr('Last Modified', 1)?></td> 
    476     <td class="h"><?php echo colheadstr('Size', 2)?></td> 
    477     <td class="h"><?php echo colheadstr('Reloads', 3)?></td> 
    478     <td class="h"><?php echo colheadstr('Hits', 4)?></td> 
     476    <td class="h"><?php echo colheadstr('Added', 2)?></td> 
     477    <td class="h"><?php echo colheadstr('TTL', 3)?></td> 
     478    <td class="h"><?php echo colheadstr('Size', 4)?></td> 
     479    <td class="h"><?php echo colheadstr('Reloads', 5)?></td> 
     480    <td class="h"><?php echo colheadstr('Hits', 6)?></td> 
    479481</tr> 
    480482<?php 
     
    489491                    $file_col = $scripts[$i]['file']; 
    490492                } 
     493 
     494                if ($scripts[$i]['ttl'] != 0) { 
     495                    $ttl_col = $scripts[$i]['ttl'] - time(); 
     496                    if ($ttl_col <= 0) { 
     497                        $ttl_col = "expired"; 
     498                    } 
     499                } else { 
     500                    $ttl_col = "&infin;"; 
     501                } 
    491502?> 
    492503<tr> 
    493504    <td class="el"><small><?php echo $file_col ?></small></td> 
    494505    <td class="fl"><small><?php echo date('Y-m-d H:i:s', $scripts[$i]['mtime'])?></small></td> 
     506    <td class="fl"><small><?php echo date('Y-m-d H:i:s', $scripts[$i]['ts'])?></small></td> 
     507    <td class="fr"><small><?php echo $ttl_col ?></small></td> 
    495508    <td class="fr"><small><?php echo format_size($scripts[$i]['size'])?></small></td> 
    496509    <td class="fr"><small><?php echo $scripts[$i]['reloads']?> (<?php echo $scripts[$i]['usecount']?>)</small></td> 
  • eaccelerator/trunk/ea_info.c

    r330 r337  
    456456            add_assoc_string(script, "file", p->realfilename, 1); 
    457457            add_assoc_long(script, "mtime", p->mtime); 
     458            add_assoc_long(script, "ts", p->ts); 
     459            add_assoc_long(script, "ttl", p->ttl); 
    458460            add_assoc_long(script, "size", p->size); 
    459461            add_assoc_long(script, "reloads", p->nreloads); 
  • eaccelerator/trunk/eaccelerator.c

    r336 r337  
    108108 
    109109/* saved original functions */ 
    110 static zend_op_array *(*mm_saved_zend_compile_file)(zend_file_handle *file_handle, int type TSRMLS_DC); 
     110static zend_op_array *(*ea_saved_zend_compile_file)(zend_file_handle *file_handle, int type TSRMLS_DC); 
    111111 
    112112#ifdef DEBUG 
    113 static void (*mm_saved_zend_execute)(zend_op_array *op_array TSRMLS_DC); 
     113static void (*ea_saved_zend_execute)(zend_op_array *op_array TSRMLS_DC); 
    114114#endif 
    115115 
     
    165165        eaccelerator_mm_instance->hash_cnt--; 
    166166        if (p->use_cnt > 0) { 
    167           /* key is used by other process/thred. Shedule it to remove */ 
     167          /* key is used by other process/thread. Shedule it for removal */ 
    168168          p->removed = 1; 
    169169          p->next = eaccelerator_mm_instance->removed; 
     
    222222      eaccelerator_mm_instance->hash[slot]->nreloads += p->nreloads; 
    223223      if (p->use_cnt > 0) { 
    224         /* key is used by other process/thred. Shedule it to remove */ 
     224        /* key is used by other process/thread. Shedule it to remove */ 
    225225        p->removed = 1; 
    226226        p->next = eaccelerator_mm_instance->removed; 
     
    746746        p->ttl = 0; 
    747747      } 
     748      p->ts       = hdr.ts;     /* get cached item creation timestamp from cache file */ 
    748749      hash_add_mm(p); 
    749750    } else { 
     
    781782    hdr.size  = p->size; 
    782783    hdr.mtime = p->mtime; 
     784    hdr.ts    = p->ts; 
    783785    p->next = p; 
    784786    hdr.crc32 = eaccelerator_crc32((const char*)p,p->size); 
     
    833835    eaccelerator_store_int(p, key, len, op_array, f, c TSRMLS_CC); 
    834836    p->mtime    = buf->st_mtime; 
     837    p->ts       = EAG(req_start); 
    835838    p->filesize = buf->st_size; 
    836839    p->size     = size; 
     
    11141117  char  realname[MAXPATHLEN]; 
    11151118  int   nreloads; 
    1116   time_t compile_time; 
    11171119  int stat_result = 0; 
    11181120#ifdef DEBUG 
     
    11411143      file_handle->filename == NULL || stat_result != 0 || !ok_to_cache) { 
    11421144    DBG(ea_debug_printf, (EA_DEBUG, "\t[%d] compile_file: compiling\n", getpid())); 
    1143     t = mm_saved_zend_compile_file(file_handle, type TSRMLS_CC); 
     1145    t = ea_saved_zend_compile_file(file_handle, type TSRMLS_CC); 
    11441146    DBG(ea_debug_printf, (EA_TEST_PERFORMANCE, "\t[%d] compile_file: end (%ld)\n", getpid(), ea_debug_elapsed_time(&tv_start))); 
    11451147    DBG(ea_debug_printf, (EA_DEBUG, "\t[%d] compile_file: end\n", getpid())); 
     
    11561158  } 
    11571159 
    1158   compile_time = EAG(req_start); 
    1159   if (buf.st_mtime >= compile_time && eaccelerator_debug > 0) { 
     1160  if (buf.st_mtime >= EAG(req_start) && eaccelerator_debug > 0) { 
    11601161        ea_debug_log("EACCELERATOR: Warning: \"%s\" is cached but it's mtime is in the future.\n", file_handle->filename); 
    11611162  } 
    11621163 
    1163   t = eaccelerator_restore(realname, &buf, &nreloads, compile_time TSRMLS_CC); 
     1164  t = eaccelerator_restore(realname, &buf, &nreloads, EAG(req_start) TSRMLS_CC); 
    11641165 
    11651166// segv74: really cheap work around to auto_global problem. 
     
    12621263    ea_bailout = 0; 
    12631264    zend_try { 
    1264       t = mm_saved_zend_compile_file(file_handle, type TSRMLS_CC); 
     1265      t = ea_saved_zend_compile_file(file_handle, type TSRMLS_CC); 
    12651266    } zend_catch { 
    12661267      CG(function_table) = orig_function_table; 
     
    13821383  EAG(profile_level)++; 
    13831384  ea_debug_printf(EA_PROFILE_OPCODES, "About to enter zend_execute...\n"); 
    1384   mm_saved_zend_execute(op_array TSRMLS_CC); 
     1385  ea_saved_zend_execute(op_array TSRMLS_CC); 
    13851386  ea_debug_printf(EA_PROFILE_OPCODES, "Finished zend_execute...\n"); 
    13861387  usec = ea_debug_elapsed_time(&tv_start); 
     
    18531854      return FAILURE; 
    18541855    } 
    1855     mm_saved_zend_compile_file = zend_compile_file; 
     1856    ea_saved_zend_compile_file = zend_compile_file; 
    18561857 
    18571858#ifdef DEBUG 
    18581859    zend_compile_file = profile_compile_file; 
    1859     mm_saved_zend_execute = zend_execute; 
     1860    ea_saved_zend_execute = zend_execute; 
    18601861    zend_execute = profile_execute; 
    18611862#else 
     
    18851886    return SUCCESS; 
    18861887  } 
    1887   zend_compile_file = mm_saved_zend_compile_file; 
     1888  zend_compile_file = ea_saved_zend_compile_file; 
    18881889#ifdef WITH_EACCELERATOR_CONTENT_CACHING 
    18891890  eaccelerator_content_cache_shutdown(); 
  • eaccelerator/trunk/eaccelerator.h

    r330 r337  
    278278 
    279279/* 
    280  * A mm_cache_entry is a bucket for one PHP script file. 
    281  * Nested  functions and classes which defined in the file goes 
    282  * into the list of mm_fc_entry. 
     280 * A ea_cache_entry is a bucket for one PHP script file. 
     281 * User functions and classes defined in the file go into 
     282 * the list of ea_fc_entry. 
    283283 */ 
    284284typedef struct _ea_cache_entry { 
    285285        struct _ea_cache_entry *next; 
    286286#ifdef EACCELERATOR_USE_INODE 
    287         dev_t st_dev;                           /* file's device                     */ 
    288         ino_t st_ino;                           /* file's inode                      */ 
    289 #else 
    290         unsigned int hv;                        /* hash value                        */ 
     287        dev_t st_dev;                           /* file's device                         */ 
     288        ino_t st_ino;                           /* file's inode                          */ 
     289#else 
     290        unsigned int hv;                        /* hash value                            */ 
    291291#endif 
    292292        off_t filesize;                         /* file size */ 
    293         time_t mtime;                           /* file last modification time       */ 
    294         time_t ttl;                                     /* expiration time                   */ 
    295         int size;                                       /* entry size (bytes)                */ 
    296         int nhits;                                      /* hits count                        */ 
    297         int nreloads;                           /* count of reloads                  */ 
    298         int use_cnt;                            /* how many processes uses the entry */ 
     293        time_t mtime;                           /* file last modification time           */ 
     294        time_t ttl;                             /* expiration time (updated on each hit) */ 
     295        time_t ts;                              /* timestamp of cache entry              */ 
     296        unsigned int size;                      /* entry size (bytes)                    */ 
     297        unsigned int nhits;                     /* hits count                            */ 
     298        unsigned int nreloads;                  /* count of reloads                      */ 
     299        int use_cnt;                    /* how many processes uses the entry     */ 
    299300        ea_op_array *op_array;  /* script's global scope code        */ 
    300301        ea_fc_entry *f_head;            /* list of nested functions          */ 
     
    318319 
    319320/* 
    320  * Linked list of mm_cache_entry which are used by process/thread 
     321 * Linked list of ea_cache_entry which are used by process/thread 
    321322 */ 
    322323typedef struct _ea_used_entry { 
     
    344345        int size; 
    345346        time_t mtime; 
     347        time_t ts; 
    346348        unsigned int crc32; 
    347349} ea_file_header;