Changeset 522 for trunk/xcache.c
- Timestamp:
- 2008-02-17T17:49:46+01:00 (5 years ago)
- File:
-
- 1 edited
-
trunk/xcache.c (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
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 {
Note: See TracChangeset
for help on using the changeset viewer.

