Re: memPools and debugging

From: Andres Kroonmaa <andre@dont-contact.us>
Date: Mon, 22 Dec 2003 17:45:37 +0200

On 20 Dec 2003, at 14:09, Robert Collins <robertc@squid-cache.org> wrote:

> On Fri, 2003-12-19 at 22:18, Andres Kroonmaa wrote:
> > Now I wonder if it makes sense to wrap it up into some form of
> > ifdef'ed debug option into mempools, or would that clutter source
> > needlessly? It isn't perfectly portable I guess, so, I don't know.
>
> Makes sense to me.

 ok, here is attached:
 1) simple mprotect based debug patch for lib/MemPool.c
    (runs on our production cache with relatively low cpu hit)

 Note: it relies on MEM_PAGE_SIZE in MemPool.h to establish page boundary,
 which may differ depending on CPUs.

 2) patch to enable cpu profiling of memPools, which got omitted during
    merges of chunked mempools and cpu profiling.

 Please review and comment.

------------------------------------
 Andres Kroonmaa <andre@online.ee>
 CTO, Microlink Data AS
 Tel: 6501 731, Fax: 6501 725
 Pärnu mnt. 158, Tallinn
 11317 Estonia

The following section of this message contains a file attachment
prepared for transmission using the Internet MIME message format.
If you are using Pegasus Mail, or any another MIME-compliant system,
you should be able to save it or view it from within your mailer.
If you cannot, please ask your system administrator for assistance.

   ---- File information -----------
     File: mprotect.dif
     Date: 22 Dec 2003, 17:37
     Size: 5465 bytes.
     Type: Text

--- MemPool.c Mon Dec 22 17:41:52 2003
+++ MemPool.c.newall Mon Dec 22 17:41:29 2003
@@ -81,6 +81,7 @@
  */
 
 #include "config.h"
+#include "profiling.h"
 
 #define FLUSH_LIMIT 1000 /* Flush memPool counters to memMeters after flush limit calls */
 #define MEM_MAX_MMAP_CHUNKS 2048
@@ -255,6 +256,7 @@
     void **Free;
     MemChunk *chunk;
 
+ PROF_start(memPoolChunkNew);
     chunk = xcalloc(1, sizeof(MemChunk)); /* should have a pool for this too */
 #if (DEBUG_MEMPOOLS & 4)
     if ( (pool->obj_size & (MEM_PAGE_SIZE-1)) == 0) {
@@ -278,6 +280,7 @@
     chunk->lastref = squid_curtime;
     lastPool = pool;
     pool->allChunks = splay_insert(chunk, pool->allChunks, memCompChunks);
+ PROF_stop(memPoolChunkNew);
     return chunk;
 }
 #endif
@@ -599,6 +602,7 @@
 memPoolAlloc(MemPool * pool)
 {
     void *p;
+ PROF_start(memPoolAlloc);
     assert(pool != NULL);
 #if !DISABLE_POOLS
     p = memPoolGet(pool);
@@ -611,12 +615,14 @@
     if (++pool->alloc_calls == FLUSH_LIMIT)
         memPoolFlushMeters(pool);
 
+ PROF_stop(memPoolAlloc);
     return p;
 }
 
 void
 memPoolFree(MemPool * pool, void *obj)
 {
+ PROF_start(memPoolFree);
     assert(pool != NULL && obj != NULL);
 #if !DISABLE_POOLS
 
@@ -628,6 +634,7 @@
     xfree(obj);
 #endif
     ++pool->free_calls;
+ PROF_stop(memPoolFree);
 
 }
 
@@ -741,6 +748,7 @@
     MemPoolIterator *iter;
 
     int shift = 1;
+ PROF_start(memPoolClean);
     memPoolFlushMetersAll();
     if (TheMeter.idle.level > mem_idle_limit)
         maxage = shift = 0;
@@ -752,6 +760,7 @@
         }
     }
     memPoolIterateDone(&iter);
+ PROF_stop(memPoolClean);
 }
 
 /* Persistent Pool stats. for GlobalStats accumulation */

Received on Mon Dec 22 2003 - 08:59:08 MST

This archive was generated by hypermail pre-2.1.9 : Wed Dec 24 2003 - 12:00:29 MST