Update of /cvsroot/monetdb/pathfinder/runtime
In directory 23jxhf1.ch3.sourceforge.com:/tmp/cvs-serv29932/runtime

Modified Files:
      Tag: Nov2009
        pathfinder.mx 
Log Message:
propagated changes of Saturday Oct 10 2009 - Monday Oct 12 2009
from the Aug2009_NFI branch to the Nov2009 branch

  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2009/10/10 - boncz: runtime/pathfinder.mx,1.462.6.9
  some finishing touches on the subexpression caching mechanism
  
  implemented the more useful semantics of pf:session-use that waits
  for a concurrent pf:session already in progress (computing the same 
expression)
  rather than blindly recomputing it.
  - ws of pf:session-use must have access to the parent cache
  - semaphores needed to block the pf:session-use queries and wake them up
  
  fixed issues in concurrency:
  - temp doc container must be copied in pf:session-use sessions
  - structer check in updates (pf:session-use is forbidden)
  
  adapted caching garbage collection policy against ever-growing temp
  document containers.
  - hard limit of 1M nodes in it (copying the tdc then costs ~100ms)
  - terminate session if full (we cannot garbage collect it)
  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2009/10/11 - boncz: runtime/pathfinder.mx,1.462.6.10
  final touches to pf:cache
  - roll back the recent lock complications; session locking makes it unneeded
  - re-enable the code to copy the temp doc container for non-exclusive cache 
use
  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


U pathfinder.mx
Index: pathfinder.mx
===================================================================
RCS file: /cvsroot/monetdb/pathfinder/runtime/pathfinder.mx,v
retrieving revision 1.462.4.4
retrieving revision 1.462.4.5
diff -u -d -r1.462.4.4 -r1.462.4.5
--- pathfinder.mx       8 Oct 2009 16:55:31 -0000       1.462.4.4
+++ pathfinder.mx       12 Oct 2009 07:49:53 -0000      1.462.4.5
@@ -337,11 +337,11 @@
 @:w...@1(PRE_CONT,          29, void, void,void,  oid, PRE_BASE)@
 @:w...@1(ATTR_CONT,         30, void, void,void,  oid, PRE_BASE)@
 @:w...@1(PID_MAP,           31, void, bat, void,  oid, PRE_BASE)@
-@:w...@1(ATTR_OWN_PRIVATE,  32, void, bat, void,  oid, PRE_BASE)@
-@:w...@1(ATTR_OWN_SHARED,   33, void, bat, void,  oid, PRE_BASE)@
-@:w...@1(REGION_PRE,        34, void, bat, void,  oid, PRE_BASE)@
-@:w...@1(REGION_START,      35, void, bat, void,  lng, PRE_BASE)@
-@:w...@1(REGION_END,        36, void, bat, void,  lng, PRE_BASE)@
+@:w...@1(REGION_PRE,        32, void, bat, void,  oid, PRE_BASE)@
+@:w...@1(REGION_START,      33, void, bat, void,  lng, PRE_BASE)@
+@:w...@1(REGION_END,        34, void, bat, void,  lng, PRE_BASE)@
+@:w...@1(ATTR_OWN_SHARED,   35, void, bat, void,  oid, PRE_BASE)@
+@:w...@1(ATTR_OWN_PRIVATE,  36, void, bat, void,  oid, PRE_BASE)@
 @:w...@1(OPEN_NAME,         37, void, str, void, void, oid_nil)@
 @:w...@1(OPEN_DOCID,        38, void, oid, void, void, oid_nil)@
 @:w...@1(OPEN_CONT,         39, void, oid, void, void, oid_nil)@
@@ -1532,7 +1532,16 @@
             xrpc_statuses.inplace(idx, "reserved");
             if (xrpc_mode.search("use") < 0) return ws;
         }
-        ws := [access]([copy](ws),BAT_WRITE); # use a copy, no locking required
+        # use a copy of the ws so it is not affected by concurrent queries; 
give it a private cache
+        ws := [access]([copy](ws), BAT_WRITE);
+
+        # the tempdoc container must be deep copied, as read-only queries 
change it
+        var temp_doc_cont := [access]([copy]([fetch](ws.slice(0,ATTR_PROP), 
WS)), BAT_WRITE);
+        
temp_doc_cont.mark(oid(MAP_PID)).tmark(0...@0).leftfetchjoin(ws).[inplace](WS, 
temp_doc_cont.tmark(0...@0));
+        
temp_doc_cont.mark(oid(_MAP_PID)).tmark(0...@0).leftfetchjoin(ws).[inplace](WS, 
temp_doc_cont.tmark(0...@0));
+        temp_doc_cont := 
[access]([copy]([fetch](ws.slice(QN_NID,ATTR_OWN_SHARED), WS)), BAT_WRITE);
+        
temp_doc_cont.mark(oid(QN_NID)).tmark(0...@0).leftfetchjoin(ws).[inplace](WS, 
temp_doc_cont.tmark(0...@0));
+        ws.fetch(ATTR_OWN_PRIVATE).inplace(WS, ws.fetch(ATTR_OWN).fetch(WS));
     } else {
         ws := [ws_new](mirror(ws_tpe), ws_tpe, ws_htp, ws_ttp, ws_seq);
         if (xrpc < 0) {
@@ -1558,10 +1567,15 @@
     if ((xrpc_qid = "") or (xrpc_mode = "use-cache-repeatable")) {
         ws_destroy(ws);
     } else {
-        ws_cache_end(ws);
+        if (count(ws.fetch(PRE_SIZE).fetch(WS)) > 1000000) { # limit max 
tempdoc copy time to ~100ms
+            xrpc_timeout := 0LL; # if tempdoc container gets too big, we have 
to kill the ws
+        } else {
+            ws_cache_end(ws); # apply LRU to the cached subsequences
+        }
         lock_set(xrpc_lock);
-        CATCH(_ws_xrpc_end(xrpc_qid, err));
+        err := CATCH(_ws_xrpc_end(xrpc_qid, err));
         lock_unset(xrpc_lock);
+        if (not(isnil(err))) ERROR(err);
     }
     # do not auto-restart XRPC updates (deadlock danger)
     if (xrpc_method != "") return 2;
@@ -1571,9 +1585,8 @@
 PROC ws_create(int update) : BAT[void,bat]
 {
     if (bit(and(update,2)) and (xrpc_mode.search("cache") >= 0)) {
-        # updates in a session terminate the session
-        xrpc_timeout := 0;
-        xrpc_mode := "cache-repeatable";
+        if (xrpc_mode.search("use") >= 0) ERROR("ws_create(): cannot update in 
a pf:session-use session");
+        xrpc_timeout := 0; # updates in a session terminate the session
     }
 
     # NOTE: use pre-query MIL variables xrpc_qid/xrpc_timeout to possibly 
re-use an existing ws
@@ -1600,6 +1613,16 @@
         lock_unset(xrpc_lock);
         if (aborted) ERROR("ws_create: session was aborted by a previous 
query"); 
     }
+
+    if (bit(and(update,2))) {
+        # for update queries, create additional bats that will hold the deltas
+        var tpe := ws_update.hmark(oid(WS_SIZE));
+        var upd := [new](oid,tpe);
+        var unq := [=](tpe,bat);
+        [set](mirror(unq.uselect(false)).leftfetchjoin(upd), true);
+        [key](mirror(unq.uselect(true)).leftfetchjoin(upd), true);
+        ws := ws.access(BAT_WRITE).insert(upd).access(BAT_READ);
+    }
     if (xrpc > 0) return ws;
 
     # only instantiates the default views of the ws-bats (not the master bats)
@@ -1638,15 +1661,6 @@
     var wsid := ws_id(ws);
     pflock_begin(wsid);
 
-    if (bit(and(update,2))) {
-        # for update queries, create additional bats that will hold the deltas
-        var tpe := ws_update.hmark(oid(WS_SIZE));
-        var upd := [new](oid,tpe);
-        var unq := [=](tpe,bat);
-        [set](mirror(unq.uselect(false)).leftfetchjoin(upd), true);
-        [key](mirror(unq.uselect(true)).leftfetchjoin(upd), true);
-        ws := ws.access(BAT_WRITE).insert(upd).access(BAT_READ);
-    }
     if (ws_log_active)
         ws_log(ws, "===================== START TRANSACTION update-" + 
str(update));
     return ws;


------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay 
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
Monetdb-pf-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/monetdb-pf-checkins

Reply via email to