Changeset: f02dc55e483d for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=f02dc55e483d
Modified Files:
        monetdb5/mal/mal_recycle.c
        monetdb5/mal/mal_recycle.h
        monetdb5/modules/mal/recycle.c
Branch: default
Log Message:

Use benefit policy for cache management;
Add statistics for data transfer reuse.


diffs (123 lines):

diff --git a/monetdb5/mal/mal_recycle.c b/monetdb5/mal/mal_recycle.c
--- a/monetdb5/mal/mal_recycle.c
+++ b/monetdb5/mal/mal_recycle.c
@@ -138,7 +138,7 @@ int reusePolicy = REUSE_COVER;      /* recycl
  * If we run low on memory, we either deploy the LRU or
  * BENEFIT algorithm to determine the victims.
  */
-int rcachePolicy = RCACHE_LRU;  /* recycle cache management policy
+int rcachePolicy = RCACHE_BENEFIT;  /* recycle cache management policy
                        RCACHE_ALL: baseline, do nothing
                        RCACHE_LRU: evict the LRU
                        RCACHE_BENEFIT: evict items with smallest benefit= 
weight * cost
@@ -180,7 +180,9 @@ double recycleAlpha = 0.5;
 #define recycleW(X)  ((recycleBlk->profiler[X].counter + 2) * (0.05 + 
(sht)recycleBlk->profiler[X].trace) / 3.0)
 */
 
-#define recycleCost(X) (recycleBlk->profiler[X].ticks)
+/*#define recycleCost(X) (recycleBlk->profiler[X].ticks)*/
+/* ticks are not correct for octopus.bind, use wbytes insteead */
+#define recycleCost(X) (recycleBlk->profiler[X].wbytes)
 #define recycleW(X)  ((recycleBlk->profiler[X].trace && 
(recycleBlk->profiler[X].counter >1 )) ? \
                                                
(recycleBlk->profiler[X].counter -1) : 0.1 )
 
@@ -956,6 +958,14 @@ RECYCLEnew(Client cntxt, MalBlkPtr mb, M
        lng memLimit;
        lng cacheLimit;
        QryStatPtr qsp = recycleQPat->ptrn[cntxt->rcc->curQ];
+       static str octopusRef = 0, bindRef = 0, bindidxRef = 0;
+
+       if (octopusRef == 0)
+               octopusRef = putName("octopus",7);
+       if (bindRef == 0)
+               bindRef = putName("bind",4);
+       if (bindidxRef == 0)
+               bindidxRef = putName("bind_idxbat",11);
 
 /*     (void) rd;      */
        RECYCLEspace();
@@ -1027,6 +1037,11 @@ RECYCLEnew(Client cntxt, MalBlkPtr mb, M
                        "#memory="LLFMT", stop=%d, recycled=%d, executed=%d \n",
                        recyclerUsedMemory, recycleBlk->stop,
                        cntxt->rcc->recycled0, cntxt->rcc->statements);
+
+       if ( getModuleId(p) == octopusRef &&
+                        (getFunctionId(p) == bindRef || getFunctionId(p) == 
bindidxRef) )
+               recycleQPat->ptrn[cntxt->rcc->curQ]->dt += wr;
+
        cntxt->rcc->recent = i;
        cntxt->rcc->RPadded0++;
        setSelectProp(q);
diff --git a/monetdb5/mal/mal_recycle.h b/monetdb5/mal/mal_recycle.h
--- a/monetdb5/mal/mal_recycle.h
+++ b/monetdb5/mal/mal_recycle.h
@@ -90,7 +90,8 @@ typedef struct QRYSTAT {
        int calls;      /* number of calls */
        int greuse; /* number of global reuse */
        int lreuse; /* number of local reuse in current execution only */
-       lng dtreuse;/* data transfer amount in RU that query reuses from others 
*/
+       lng dt;         /* data transfer (RU) by this query */
+       lng dtreuse;/* data transfer (RU) that query reuses from others */
        int *crd;   /* instructions credits */
        int stop;
        int wl;         /* waterline of globally reused instructions*/
diff --git a/monetdb5/modules/mal/recycle.c b/monetdb5/modules/mal/recycle.c
--- a/monetdb5/modules/mal/recycle.c
+++ b/monetdb5/modules/mal/recycle.c
@@ -169,50 +169,24 @@ RECYCLEdumpQPat(stream *s)
 static void
 RECYCLEdumpDataTrans(stream *s)
 {
-       int i, n, qidx, err=0;
-       InstrPtr p;
-       lng *dt, sum = 0, rdt, rsum = 0;
-
-       static str octopusRef = 0, bindRef = 0, bindidxRef = 0;
-
-       if (octopusRef == 0)
-               octopusRef = putName("octopus",7);
-       if (bindRef == 0)
-        bindRef = putName("bind",4);
-       if (bindidxRef == 0)
-        bindidxRef = putName("bind_idxbat",11);
+       int i, n;
+       lng dt, sum = 0, rdt, rsum = 0;
 
        if (!recycleBlk || !recycleQPat)
                return;
 
        n = recycleQPat->cnt;
-       dt = GDKzalloc(sizeof(lng) * n);
-
-       for(i=0; i< recycleBlk->stop; i++){
-               p = getInstrPtr(recycleBlk,i);
-               if ( getModuleId(p) != octopusRef ||
-                        (getFunctionId(p) != bindRef && getFunctionId(p) != 
bindidxRef) )
-                        continue;
-               qidx = p->recycle;
-               if ( qidx >= 0 && qidx < n )
-                       dt[qidx] += recycleBlk->profiler[i].wbytes;
-               else err = i;
-       }
 
        mnstr_printf(s,"#Query  \t Data   \t DT Reused\n");
        mnstr_printf(s,"#pattern\t transf.\t from others\n");
        for( i=0; i < n; i++){
                rdt = recycleQPat->ptrn[i]->dtreuse;
-               mnstr_printf(s,"# %d \t\t "LLFMT"\t\t"LLFMT"\n", i, dt[i], rdt);
-               sum += dt[i];
-               rsum += rdt;
+        dt = recycleQPat->ptrn[i]->dt;
+        mnstr_printf(s,"# %d \t\t "LLFMT"\t\t"LLFMT"\n", i, dt, rdt);
+        sum += dt;
+        rsum += rdt;
        }
        mnstr_printf(s,"#########\n# Total transfer "LLFMT" Total reused 
"LLFMT"\n", sum, rsum);
-       if (err)
-               mnstr_printf(s,"# CL %d points to missing query pattern\n",
-                       getInstrPtr(recycleBlk,err)->recycle );
-
-       GDKfree(dt);
 }
 
 str
_______________________________________________
Checkin-list mailing list
[email protected]
http://mail.monetdb.org/mailman/listinfo/checkin-list

Reply via email to