Update of /cvsroot/monetdb/MonetDB5/src/mal
In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv32041

Modified Files:
        mal_instruction.mx mal_recycle.mx 
Log Message:
mal_instruction - better make sute the profiler table remains aligned
when the block grows

mal_recycle  = round of debugging


Index: mal_recycle.mx
===================================================================
RCS file: /cvsroot/monetdb/MonetDB5/src/mal/mal_recycle.mx,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -d -r1.16 -r1.17
--- mal_recycle.mx      8 Mar 2008 12:42:23 -0000       1.16
+++ mal_recycle.mx      9 Mar 2008 08:39:35 -0000       1.17
@@ -95,7 +95,7 @@
 int recycleVersion = 0;  /* version of recycle table */
 MalBlkPtr recycleBlk = NULL;
 
-int retainPolicy = 0;  /* recycle retainment policy
+int retainPolicy = 1;  /* recycle retainment policy
                        0: baseline, keeps stat, no retain, no reuse
                        1: infinite case, retain all
                        2: time-based semantics, retain if beneficial 
@@ -103,7 +103,7 @@
 int retainTime = 0;
 size_t retainSize = 0;
 
-int reusePolicy = 0;   /* recycle reuse policy
+int reusePolicy = 2;   /* recycle reuse policy
                        0: baseline, keeps stat, no retain, no reuse
                        1: reuse smallest select covering 
                        2: exact covering  */
@@ -124,27 +124,11 @@
 @c
 static void RECYCLEspace()
 {
-       InstrPtr p;
-       ProfPtr old;
-       int osize;
-
        if ( recycleBlk == NULL) {
                recycleBlk = newMalBlk(MAXVARS, STMT_INCREMENT);
                recycleBlk->profiler = (ProfPtr) GDKzalloc(
                        recycleBlk->ssize*sizeof(ProfRecord));
        }
-       if( recycleBlk->stop +1 >= recycleBlk->ssize){
-               old = recycleBlk->profiler;
-               osize= recycleBlk->ssize;
-               p=newInstruction(recycleBlk, ASSIGNsymbol);
-               pushInstruction(recycleBlk, p);
-               removeInstruction(recycleBlk,p);  /* back to alloc space  */
-               if( recycleBlk->profiler == NULL)
-                       recycleBlk->profiler = (ProfPtr) GDKzalloc(
-                               recycleBlk->ssize*sizeof(ProfRecord));
-               memcpy((char*) recycleBlk->profiler, (char*) old, 
-                       sizeof(ProfRecord)*osize);
-       }
 }
 
 void RECYCLEversion(MalBlkPtr mb)
@@ -205,17 +189,26 @@
 {
        int i, j, c; 
        ValRecord *v;
+       ValRecord cst;
        InstrPtr q;
        
        RECYCLEspace();
        if( recycleCacheLimit  &&
                recycleCacheLimit < recycleBlk->stop)
                        return; /* no more caching */
+
+       if( p->argc <=1 )       /* add more */
+                       return;
+#ifdef _DEBUG_RECYCLE_
+       stream_printf(GDKout,"RECYCLE new instruction \n");
+       printInstruction(GDKout,mb,p,LIST_MAL_ALL);
+#endif
        q = copyInstruction(p);
        for(i = 0; i< p->argc; i++){
                j= getArg(p,i);
                v = &s->stk[j];
-               c = defConstant(recycleBlk, v->vtype, v);
+               VALcopy(&cst,v);
+               c = defConstant(recycleBlk, v->vtype, &cst);
                if (v->vtype == TYPE_bat)
                        BBPincref( *(int*)VALget(v), TRUE);
                setArg(q,i,c);
@@ -260,7 +253,7 @@
                stream_printf(GDKout,"RECYCLEreuse policy %d  recycleBlk %d\n",
                        reusePolicy, recycleBlk==0);
 #endif
-       if( recycleBlk == 0)
+       if( recycleBlk == 0 || reusePolicy == 0)
                return 0;
 
        for (i = 0; i < recycleBlk->stop; i++){
@@ -272,13 +265,14 @@
 
                switch(reusePolicy){
                case 0:
-                       /* 0: baseline, keeps stat, no retain, no reuse*/
+                       /* 0: baseline, no retain, no reuse*/
                        break;
                case 1:
                        /* 1: reuse smallest range covering */
-                       ridx= mb->var[getArg(p,1)]->recycle;
+                       ridx= getArg(q,1);
                        idx= getArg(p,1);
-                       if( (getFunctionId(p)== selectRef || 
+                       if( q->argc == p->argc &&
+                               (getFunctionId(p)== selectRef || 
                                 getFunctionId(p)== uselectRef)   &&
                                getVarConstant(recycleBlk,ridx).val.bval == 
s->stk[idx].val.bval)
                        {       

Index: mal_instruction.mx
===================================================================
RCS file: /cvsroot/monetdb/MonetDB5/src/mal/mal_instruction.mx,v
retrieving revision 1.303
retrieving revision 1.304
diff -u -d -r1.303 -r1.304
--- mal_instruction.mx  5 Mar 2008 00:08:48 -0000       1.303
+++ mal_instruction.mx  9 Mar 2008 08:39:35 -0000       1.304
@@ -2097,13 +2097,19 @@
                }
                memcpy(newblk, mb->stmt, mb->ssize * sizeof(InstrPtr));
 
+               /* also extend the storage space for the profiler */
+               /* left to the environment */
+               if( mb->profiler){
+                       ProfPtr old = mb->profiler;
+                       int osize = mb->ssize;
+                       mb->profiler = (ProfPtr) GDKzalloc(
+                               (mb->ssize + 
STMT_INCREMENT)*sizeof(ProfRecord));
+                       memcpy((char*) mb->profiler, (char*) old, 
sizeof(ProfRecord)*osize);
+                       GDKfree(old);
+               }
                mb->ssize += STMT_INCREMENT;
                GDKfree(mb->stmt);
                mb->stmt = newblk;
-               /* also extend the storage space for the profiler */
-               /* left to the environment */
-               if( mb->profiler)
-                       mb->profiler= NULL;
        }
 @-
 If the destination variable has not been set, introduce a temporary


-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Monetdb-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/monetdb-checkins

Reply via email to