Changeset 522
- Timestamp:
- 02/17/2008 05:49:46 PM (5 years ago)
- Location:
- trunk
- Files:
-
- 14 modified
-
Decompiler.class.php (modified) (4 diffs)
-
admin/common-zh-simplified-utf-8.lang.php (modified) (1 diff)
-
admin/common-zh-traditional-utf-8.lang.php (modified) (1 diff)
-
admin/help-en.lang.php (modified) (1 diff)
-
admin/help-zh-simplified-utf-8.lang.php (modified) (1 diff)
-
admin/xcache.css (modified) (1 diff)
-
admin/xcache.php (modified) (3 diffs)
-
admin/xcache.tpl.php (modified) (4 diffs)
-
mkopcode_spec.awk (modified) (1 diff)
-
phpdc.phpr (modified) (1 diff)
-
run-xcachetest (modified) (1 diff)
-
utils.h (modified) (1 diff)
-
xcache.c (modified) (6 diffs)
-
xcache.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Decompiler.class.php
r393 r522 29 29 if (is_array($src)) { 30 30 die_error('array str'); 31 $src = new Decompiler_Array($src );32 return $src->__toString( $indent);31 $src = new Decompiler_Array($src, false, $indent); 32 return $src->__toString(); 33 33 } 34 34 … … 165 165 } 166 166 167 function __toString( $indent)168 { 169 return $this->obj->__toString( $indent);167 function __toString() 168 { 169 return $this->obj->__toString(); 170 170 } 171 171 } … … 258 258 { 259 259 var $needExport = false; 260 261 function Decompiler_Array($value = array(), $needexport = false) 260 var $indent = ''; 261 262 function Decompiler_Array($value = array(), $needexport = false, $indent = '') 262 263 { 263 264 $this->value = $value; 264 265 $this->needExport = $needexport; 265 } 266 267 function __toString($indent) 266 $this->indent = $indent; 267 } 268 269 function __toString() 268 270 { 269 271 $exp = "array("; 270 $indent .=INDENT;272 $indent = $this->indent . INDENT; 271 273 $assoclen = 0; 272 274 $multiline = 0; … … 335 337 var $iskey; 336 338 337 function __toString( $indent)339 function __toString() 338 340 { 339 341 return 'foreach (' . ''; -
trunk/admin/common-zh-simplified-utf-8.lang.php
r521 r522 28 28 'Hits' 29 29 => '命中', 30 'Hits 24H' 31 => '24H 分布', 32 'Hits/H' 33 => '命中/H', 34 'Hits/S' 35 => '命中/S', 30 36 'Misses' 31 37 => '错过', -
trunk/admin/common-zh-traditional-utf-8.lang.php
r521 r522 28 28 'Hits' 29 29 => '命中', 30 'Hits 24H' 31 => '24H 分布', 32 'Hits/H' 33 => '命中/H', 34 'Hits/S' 35 => '命中/S', 30 36 'Misses' 31 37 => '錯過', -
trunk/admin/help-en.lang.php
r458 r522 8 8 <dt><?php echo _T('Compiling'); ?>: </dt><dd>Compiling flag, "yes" if the cache is busy compiling php script</dd> 9 9 <dt><?php echo _T('Hits'); ?>: </dt><dd>Cache Hits, hit=a var/php is loaded from this cache</dd> 10 <dt><?php echo _T('Hits/H'); ?>: </dt><dd>Average Hits per Hour. Only last 24 hours is logged</dd> 11 <dt><?php echo _T('Hits 24H'); ?>: </dt><dd>Hits 24 Hours. Hits graph of last 24 hours</dd> 12 <dt><?php echo _T('Hits/S'); ?>: </dt><dd>Average Hits per Second. Only last 5 seconds is logged</dd> 10 13 <dt><?php echo _T('Misses'); ?>: </dt><dd>Cache Misses, miss=a var/php is requested but not in the cache</dd> 11 14 <dt><?php echo _T('Clogs'); ?>: </dt><dd>Compiling Clogs, clog=compiling is needed but avoided to wait(be blocked) when the cache is busy compiling already</dd> -
trunk/admin/help-zh-simplified-utf-8.lang.php
r458 r522 8 8 <dt><?php echo _T('Compiling'); ?>: </dt><dd>编译标记, 当共享内存区正在编译 php 脚本时标记为 "yes"</dd> 9 9 <dt><?php echo _T('Hits'); ?>: </dt><dd>共享内存命中次数, 命中=从该共享内存载入php或者变量</dd> 10 <dt><?php echo _T('Hits/H'); ?>: </dt><dd>每小时命中次数. 只统计最后 24 小时</dd> 11 <dt><?php echo _T('Hits 24H'); ?>: </dt><dd>24 小时命中分布图. 图表现是最后 24 小时的命中次数</dd> 12 <dt><?php echo _T('Hits/S'); ?>: </dt><dd>每秒命中次数. 只统计最后 5 秒</dd> 10 13 <dt><?php echo _T('Misses'); ?>: </dt><dd>共享内存错过次数, 错过=请求的php或者变量并不在该共享内存内</dd> 11 14 <dt><?php echo _T('Clogs'); ?>: </dt><dd>编译阻塞跳过, 阻塞=当需该共享内存区负责编译时, 其他进程/现成无法访问此共享内存. 跳过=XCache 自动判断阻塞的共享内存区自动跳过阻塞等待, 直接使用非共享内存方式继续处理请求</dd> -
trunk/admin/xcache.css
r521 r522 28 28 .freeblockgraph { border: 1px solid gray; border-bottom: 0px; } 29 29 30 .hitsgraph { height: 20px; border: solid gray; border-width: 1px 0 1px 0; margin: auto; } 31 .hitsgraph div { float: left; width: 2px; height: 100%; } 32 .bitsgraph div div { float: none; width: 100%; } 33 30 34 .switcher, h1, h2 { text-align: center; display: block; } 31 35 .switcher * { color: blue; } -
trunk/admin/xcache.php
r521 r522 110 110 $b = $c; 111 111 $html[] = '<div style="background: rgb(' . "$r,$g,$b" . ')"></div>'; 112 } 113 return implode('', $html); 114 } 115 116 function calc_total(&$total, $data) 117 { 118 foreach ($data as $k => $v) { 119 switch ($k) { 120 case 'type': 121 case 'cache_name': 122 case 'cacheid': 123 case 'free_blocks': 124 continue 2; 125 } 126 if (!isset($total[$k])) { 127 $total[$k] = $v; 128 } 129 else { 130 switch ($k) { 131 case 'his_by_hour': 132 case 'his_by_second': 133 foreach ($data[$k] as $kk => $vv) { 134 $total[$k][$kk] += $vv; 135 } 136 break; 137 138 default: 139 $total[$k] += $v; 140 } 141 } 142 } 143 } 144 145 function array_avg($a) 146 { 147 if (count($a) == 0) { 148 return ''; 149 } 150 return array_sum($a) / count($a); 151 } 152 153 function bar_percent($percent) 154 { 155 $r = 220 + (int) ($percent * 25); 156 $g = $b = 220 - (int) ($percent * 220); 157 $percent = (int) ($percent * 100); 158 return '<div>' 159 . '<div style="height: ' . (100 - $percent) . '%"></div>' 160 . '<div style="background: rgb(' . "$r,$g,$b" . '); height: ' . $percent . '%"></div>' 161 . '</div>'; 162 } 163 164 function hits_to_graph($hits) 165 { 166 $max = 0; 167 foreach ($hits as $v) { 168 if ($max < $v) { 169 $max = $v; 170 } 171 } 172 if (!$max) { 173 return ''; 174 } 175 $html = array(); 176 foreach ($hits as $v) { 177 $html[] = bar_percent($v / $max); 112 178 } 113 179 return implode('', $html); … … 196 262 $cacheinfos[] = $data; 197 263 if ($pcnt >= 2) { 198 foreach ($data as $k => $v) { 199 switch ($k) { 200 case 'type': 201 case 'cache_name': 202 case 'cacheid': 203 case 'free_blocks': 204 continue 2; 205 } 206 if (!isset($total[$k])) { 207 $total[$k] = $v; 208 } 209 else { 210 $total[$k] += $v; 211 } 212 } 264 calc_total($total, $data); 213 265 } 214 266 } … … 234 286 $cacheinfos[] = $data; 235 287 if ($pcnt >= 2) { 236 foreach ($data as $k => $v) { 237 switch ($k) { 238 case 'type': 239 case 'cache_name': 240 case 'cacheid': 241 case 'free_blocks': 242 case 'gc': 243 continue 2; 244 } 245 if (!isset($total[$k])) { 246 $total[$k] = $v; 247 } 248 else { 249 $total[$k] += $v; 250 } 251 } 288 calc_total($total, $data); 252 289 } 253 290 } -
trunk/admin/xcache.tpl.php
r521 r522 17 17 <col align="right" /> 18 18 <col align="right" /> 19 <col /> 20 <col align="right" /> 21 <col align="right" /> 19 22 <col align="right" /> 20 23 <col align="right" /> … … 32 35 <th><?php echo _T('Compiling'); ?></th> 33 36 <th><?php echo _T('Hits'); ?></th> 37 <th><?php echo _T('Hits/H'); ?></th> 38 <th><?php echo _T('Hits 24H'); ?></th> 39 <th><?php echo _T('Hits/S'); ?></th> 34 40 <th><?php echo _T('Misses'); ?></th> 35 41 <th><?php echo _T('Clogs'); ?></th> … … 65 71 $ci_avail = size($ci['avail']); 66 72 $ci = number_formats($ci, $numkeys); 73 74 $hits_avg_h = number_format(array_avg($ci['hits_by_hour']), 2); 75 $hits_avg_s = number_format(array_avg($ci['hits_by_second']), 2); 76 $hits_graph_h = hits_to_graph($ci['hits_by_hour']); 77 $hits_graph_h_w = count($ci['hits_by_hour']) * 2; 78 67 79 if (!empty($ci['istotal'])) { 68 80 $ci['compiling'] = '-'; … … 95 107 <td>{$ci['compiling']}</td> 96 108 <td>{$ci['hits']}</td> 109 <td>{$hits_avg_h}</td> 110 <td><div class="hitsgraph" style="width: {$hits_graph_h_w}px">{$hits_graph_h}</div></td> 111 <td>{$hits_avg_s}</td> 97 112 <td>{$ci['misses']}</td> 98 113 <td>{$ci['clogs']}</td> -
trunk/mkopcode_spec.awk
r393 r522 15 15 exit 16 16 } 17 printf "\tOPSPEC(%10s, %10s, %10s, %10s)\n", array[1], array[2], array[3], array[4] 17 comment = ""; 18 if (match($0, /\/\* (\d+) \*\//, comments)) { 19 comment = comments[1]; 20 } 21 printf "\tOPSPEC(%10s, %10s, %10s, %10s)%s\n", array[1], array[2], array[3], array[4], comment; 18 22 next 19 23 } -
trunk/phpdc.phpr
r52 r522 13 13 } 14 14 15 $dc = &new Decompiler();15 $dc = new Decompiler(); 16 16 if (isset($argv[1])) { 17 17 $dc->decompileFile($argv[1]); -
trunk/run-xcachetest
r271 r522 19 19 if test -z "$TEST_PHP_USER" ; then 20 20 TEST_PHP_USER="$PHP_SRC/tests" 21 for i in Zend ZendEngine2 ext/standard/tests ext/reflection/tests ; do21 for i in Zend ZendEngine2 ext/standard/tests ext/reflection/tests ext/spl/tests; do 22 22 if test -d "$PHP_SRC/$i" ; then 23 23 TEST_PHP_USER="$TEST_PHP_USER,$PHP_SRC/$i" -
trunk/utils.h
r506 r522 100 100 #ifdef E_STRICT 101 101 int orig_user_error_handler_error_reporting; 102 ZEND_APIvoid (*orig_zend_error_cb)(int type, const char *error_filename, const uint error_lineno, const char *format, va_list args);102 void (*orig_zend_error_cb)(int type, const char *error_filename, const uint error_lineno, const char *format, va_list args); 103 103 zend_uint compilererror_cnt; 104 104 zend_uint compilererror_size; -
trunk/xcache.c
r516 r522 313 313 /* }}} */ 314 314 #endif 315 static inline zend_uint advance_wrapped(zend_uint val, zend_uint count) /* {{{ */ 316 { 317 if (val + 1 >= count) { 318 return 0; 319 } 320 return val + 1; 321 } 322 /* }}} */ 323 static void xc_counters_inc(time_t *curtime, zend_uint *curslot, time_t period, zend_ulong *counters, zend_uint count TSRMLS_DC) /* {{{ */ 324 { 325 time_t n = XG(request_time) / period; 326 if (*curtime != n) { 327 zend_uint target_slot = n % count; 328 if (n - *curtime > period) { 329 memset(counters, 0, sizeof(counters[0]) * count); 330 } 331 else { 332 zend_uint slot; 333 for (slot = advance_wrapped(*curslot, count); 334 slot != target_slot; 335 slot = advance_wrapped(slot, count)) { 336 counters[slot] = 0; 337 } 338 counters[target_slot] = 0; 339 } 340 *curtime = n; 341 *curslot = target_slot; 342 } 343 counters[*curslot] ++; 344 } 345 /* }}} */ 346 static void xc_cache_hit_dmz(xc_cache_t *cache TSRMLS_DC) /* {{{ */ 347 { 348 cache->hits ++; 349 350 xc_counters_inc(&cache->hits_by_hour_cur_time 351 , &cache->hits_by_hour_cur_slot, 60 * 60 352 , cache->hits_by_hour 353 , sizeof(cache->hits_by_hour) / sizeof(cache->hits_by_hour[0]) 354 TSRMLS_CC); 355 356 xc_counters_inc(&cache->hits_by_second_cur_time 357 , &cache->hits_by_second_cur_slot 358 , 1 359 , cache->hits_by_second 360 , sizeof(cache->hits_by_second) / sizeof(cache->hits_by_second[0]) 361 TSRMLS_CC); 362 } 363 /* }}} */ 315 364 316 365 /* helper function that loop through each entry */ … … 455 504 static void xc_fillinfo_dmz(int cachetype, xc_cache_t *cache, zval *return_value TSRMLS_DC) /* {{{ */ 456 505 { 457 zval *blocks; 506 zval *blocks, *hits; 507 int i; 458 508 const xc_block_t *b; 459 509 #ifndef NDEBUG … … 487 537 add_assoc_null_ex(return_value, ZEND_STRS("gc")); 488 538 } 539 MAKE_STD_ZVAL(hits); 540 array_init(hits); 541 for (i = 0; i < sizeof(cache->hits_by_hour) / sizeof(cache->hits_by_hour[0]); i ++) { 542 add_next_index_long(hits, (long) cache->hits_by_hour[i]); 543 } 544 add_assoc_zval_ex(return_value, ZEND_STRS("hits_by_hour"), hits); 545 546 MAKE_STD_ZVAL(hits); 547 array_init(hits); 548 for (i = 0; i < sizeof(cache->hits_by_second) / sizeof(cache->hits_by_second[0]); i ++) { 549 add_next_index_long(hits, (long) cache->hits_by_second[i]); 550 } 551 add_assoc_zval_ex(return_value, ZEND_STRS("hits_by_second"), hits); 489 552 490 553 MAKE_STD_ZVAL(blocks); … … 1257 1320 stored_xce = xc_entry_find_dmz(&xce TSRMLS_CC); 1258 1321 if (stored_xce) { 1259 cache->hits ++;1322 xc_cache_hit_dmz(cache TSRMLS_CC); 1260 1323 1261 1324 TRACE("hit %s, holding", stored_xce->name.str.val); … … 2113 2176 } LEAVE_LOCK(xce.cache); 2114 2177 if (found) { 2115 xc e.cache->hits ++;2178 xc_cache_hit_dmz(xce.cache TSRMLS_CC); 2116 2179 } 2117 2180 else { … … 2194 2257 } LEAVE_LOCK(xce.cache); 2195 2258 if (found) { 2196 xc e.cache->hits ++;2259 xc_cache_hit_dmz(xce.cache TSRMLS_CC); 2197 2260 } 2198 2261 else { -
trunk/xcache.h
r506 r522 224 224 time_t last_gc_deletes; 225 225 time_t last_gc_expires; 226 227 time_t hits_by_hour_cur_time; 228 zend_uint hits_by_hour_cur_slot; 229 zend_ulong hits_by_hour[24]; 230 time_t hits_by_second_cur_time; 231 zend_uint hits_by_second_cur_slot; 232 zend_ulong hits_by_second[5]; 226 233 } xc_cache_t; 227 234 /* }}} */

