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

Modified Files:
        mal_instruction.mx mal_recycle.mx 
Log Message:
A few more policies


Index: mal_recycle.mx
===================================================================
RCS file: /cvsroot/monetdb/MonetDB5/src/mal/mal_recycle.mx,v
retrieving revision 1.28
retrieving revision 1.29
diff -u -d -r1.28 -r1.29
--- mal_recycle.mx      11 Mar 2008 07:52:03 -0000      1.28
+++ mal_recycle.mx      11 Mar 2008 10:50:34 -0000      1.29
@@ -84,13 +84,15 @@
 #define REUSE_EXACT    2
 
 mal_export int rcachePolicy;
-#define RCACHE_NONE            0
-#define RCACHE_ALL             1
+#define RCACHE_ALL             0
 #define RCACHE_LRU             1
 #define RCACHE_CREDIT  2
+#define RCACHE_MEMLRU  3
+#define RCACHE_MEMCRD  4
 
 mal_export int recycleClaim;
 mal_export int recycleCacheLimit;
+mal_export long recycleMemory; /* Units of memory permitted */
 mal_export MT_Lock recycleLock;
 mal_export MalBlkPtr recycleBlk;
 mal_export double recycleAlpha;
@@ -153,15 +155,21 @@
 a simple LRU scheme, which monitors touching the 
 cache for update. The alternative is RCACHE_CREDIT,
 which uses the volumetric cost in combination with their
-reuse count to retain expensive
-instructions as long as possible.
+reuse count to retain expensive instructions as long as possible.
+The last policy keeps an eye on the total memory use of the
+intermediates stored in the recycle pool.
+If we run low on memory, we either deploy the LRU or
+CREDIT algorithm to determine the victims.
 @c
-int rcachePolicy = RCACHE_NONE;  /* recycle cache management policy
-                       RCACHE_NONE: baseline, do nothing
+int rcachePolicy = RCACHE_ALL;  /* recycle cache management policy
+                       RCACHE_ALL: baseline, do nothing
                        RCACHE_LRU: throw LRU by setting the limit
-                       RCACHE_CREDIT: credit-based LRU scheme */
+                       RCACHE_CREDIT: credit-based LRU scheme
+                       RCACHE_MEMLRU: reduce the storage overhead 
+                       RCACHE_MEMCRD: reduce the storage overhead */
 int recycleCacheLimit=0;
 int recycleClaim=0;            /* avoid stale tables by letting users mark it 
*/
+long recycleMemory=0;  /* Units of memory permitted */
 @=
 The profiler record is re-used to store recycler information.
 The clk is used by the LRU scheme, counter is the number of
@@ -215,20 +223,41 @@
 For the recycle cache LRU scheme we mis-use a field in
 the performance record.
 @c
+long RECYCLEfootprint(){
+       long cnt;
+       int i;
+       for( i=0; i<recycleBlk->stop; i++)
+               cnt += recycleBlk->profiler[i].sbytes;
+       return cnt;
+}
+
 void RECYCLEcache(){
        int i, max;
        InstrPtr pc;
+       int mem= RECYCLEfootprint() > recycleMemory;
 
        max= 0;
        for(i=0; i< recycleBlk->stop; i++){
                recycleBlk->profiler[i].clk++;
-               if( rcachePolicy == RCACHE_LRU &&
-                        recycleBlk->profiler[max].clk 
<recycleBlk->profiler[i].clk)
-                       max = i;
-               if( rcachePolicy == RCACHE_CREDIT && 
-                               recycleBlk->profiler[max].counter * 
recycleCost(max) > 
-                               recycleBlk->profiler[i].counter * 
recycleCost(i) )
-                       max = i;
+               switch(rcachePolicy){
+               case RCACHE_LRU:
+                       if( recycleBlk->profiler[max].clk 
<recycleBlk->profiler[i].clk)
+                               max = i;
+                       break;
+               case RCACHE_CREDIT:
+                       if( recycleBlk->profiler[max].counter * 
recycleCost(max) > 
+                                       recycleBlk->profiler[i].counter * 
recycleCost(i) )
+                               max = i;
+                       break;
+               case RCACHE_MEMLRU:
+                       if(mem && recycleBlk->profiler[max].clk 
<recycleBlk->profiler[i].clk)
+                               max = i;
+                       break;
+               case RCACHE_MEMCRD:
+                       if(mem && recycleBlk->profiler[max].counter * 
recycleCost(max) > 
+                                       recycleBlk->profiler[i].counter * 
recycleCost(i) )
+                               max = i;
+               }
        }
        if( recycleBlk->stop > recycleCacheLimit && recycleClaim <= 1){
 #ifdef _DEBUG_RECYCLE_

Index: mal_instruction.mx
===================================================================
RCS file: /cvsroot/monetdb/MonetDB5/src/mal/mal_instruction.mx,v
retrieving revision 1.305
retrieving revision 1.306
diff -u -d -r1.305 -r1.306
--- mal_instruction.mx  10 Mar 2008 14:03:55 -0000      1.305
+++ mal_instruction.mx  11 Mar 2008 10:50:32 -0000      1.306
@@ -395,6 +395,7 @@
        bit trace;              /* facilitate filter-based profiling */
        int     ibytes;         /* bytes read by an instruction */
        int obytes;             /* bytes written by an instruction */
+       int sbytes;             /* bytes acually consumed by an instruction */
 } *ProfPtr, ProfRecord;
 
 typedef struct MALBLK {


-------------------------------------------------------------------------
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