[prev in list] [next in list] [prev in thread] [next in thread] 

List:       pecl-cvs
Subject:    [PECL-CVS] cvs: pecl /apc apc_cache.c
From:       "Rasmus Lerdorf" <rasmus () php ! net>
Date:       2006-02-27 16:29:43
Message-ID: cvsrasmus1141057783 () cvsserver
[Download RAW message or body]

rasmus		Mon Feb 27 16:29:43 2006 UTC

  Modified files:              
    /pecl/apc	apc_cache.c 
  Log:
  This new allocator is much faster and doesn't slow down drastically 
  anymore when it has to deal with a lot of small holes.  So let's try
  turning on the staleness expunge on a full cache condition again.  If
  the TTL for the cache is 0, then we have no staleness setting to work
  from in which case we wipe out the entire cache.
  
  
http://cvs.php.net/viewcvs.cgi/pecl/apc/apc_cache.c?r1=3.105&r2=3.106&diff_format=u
Index: pecl/apc/apc_cache.c
diff -u pecl/apc/apc_cache.c:3.105 pecl/apc/apc_cache.c:3.106
--- pecl/apc/apc_cache.c:3.105	Sat Feb 25 19:50:33 2006
+++ pecl/apc/apc_cache.c	Mon Feb 27 16:29:43 2006
@@ -28,7 +28,7 @@
 
  */
 
-/* $Id: apc_cache.c,v 3.105 2006/02/25 19:50:33 rasmus Exp $ */
+/* $Id: apc_cache.c,v 3.106 2006/02/27 16:29:43 rasmus Exp $ */
 
 #include "apc_cache.h"
 #include "apc_lock.h"
@@ -335,68 +335,67 @@
 /* {{{ apc_cache_expunge */
 void apc_cache_expunge(apc_cache_t* cache, time_t t)
 {
-#if 1
     int i;
+
     if(!cache) return;
-    /* 
-       Trying to delete only stale entries blows a million tiny little
-       holes in our cache causing excessive fragmentation.  So let's
-       try just clearing it here instead and bumping the expunges count
-       to give us a hint that we need to tune the configuration.
-    */
-    LOCK(cache);
-    cache->header->expunges++;
-    for (i = 0; i < cache->num_slots; i++) {
-        slot_t* p = cache->slots[i];
-        while (p) {
-            remove_slot(cache, &p);
+
+    if(!cache->ttl) {
+        /* 
+         * If cache->ttl is not set, we wipe out the entire cache when
+         * we run out of space. 
+         */
+        LOCK(cache);
+        cache->header->expunges++;
+        for (i = 0; i < cache->num_slots; i++) {
+            slot_t* p = cache->slots[i];
+            while (p) {
+                remove_slot(cache, &p);
+            }
+            cache->slots[i] = NULL;
         }
-        cache->slots[i] = NULL;
-    }
-    UNLOCK(cache);
-#else
-    int i;
-    slot_t **p;
+        UNLOCK(cache);
+    } else {
+        slot_t **p;
 
-    /*
-     * We don't do any cache cleanup here unless the ttl for the cache
-     * has been set.  For the user cache that is slightly confusing since
-     * we have the individual entry ttl's we can look at, but that would be
-     * too much work.  So if you want the user cache expunged, set a high
-     * default apc.user_ttl and still provide a specific ttl for each entry
-     * on insert
-     */
-    if(!cache || (cache && !cache->ttl)) return;
+        /*
+         * If the ttl for the cache is set we walk through and delete stale 
+         * entries.  For the user cache that is slightly confusing since
+         * we have the individual entry ttl's we can look at, but that would be
+         * too much work.  So if you want the user cache expunged, set a high
+         * default apc.user_ttl and still provide a specific ttl for each entry
+         * on insert
+         */
 
-    LOCK(cache);
-    for (i = 0; i < cache->num_slots; i++) {
-        p = &cache->slots[i];
-        while(*p) {
-            /* 
-             * For the user cache we look at the individual entry ttl values
-             * and if not set fall back to the default ttl for the user cache
-             */
-            if((*p)->value->type == APC_CACHE_ENTRY_USER) {
-                if((*p)->value->data.user.ttl) {
-                    if((*p)->creation_time + (*p)->value->data.user.ttl < t) {
-                        remove_slot(cache, p);
-                        continue;
-                    }
-                } else if(cache->ttl) {
-                    if((*p)->creation_time + cache->ttl < t) {
-                        remove_slot(cache, p);
-                        continue;
+        LOCK(cache);
+        cache->header->expunges++;
+        for (i = 0; i < cache->num_slots; i++) {
+            p = &cache->slots[i];
+            while(*p) {
+                /* 
+                 * For the user cache we look at the individual entry ttl values
+                 * and if not set fall back to the default ttl for the user cache
+                 */
+                if((*p)->value->type == APC_CACHE_ENTRY_USER) {
+                    if((*p)->value->data.user.ttl) {
+                        if((*p)->creation_time + (*p)->value->data.user.ttl < t) {
+                            remove_slot(cache, p);
+                            continue;
+                        }
+                    } else if(cache->ttl) {
+                        if((*p)->creation_time + cache->ttl < t) {
+                            remove_slot(cache, p);
+                            continue;
+                        }
                     }
+                } else if((*p)->access_time < (t - cache->ttl)) {
+                    remove_slot(cache, p);
+                    continue;
                 }
-            } else if((*p)->access_time < (t - cache->ttl)) {
-                remove_slot(cache, p);
-                continue;
+                p = &(*p)->next;
             }
-            p = &(*p)->next;
         }
+        UNLOCK(cache);
     }
-    UNLOCK(cache);
-#endif
 }
 /* }}} */
 

-- 
PECL CVS Mailing List 
To unsubscribe, visit: http://www.php.net/unsub.php

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic