Update of /cvsroot/monetdb/pathfinder/runtime
In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv19118

Modified Files:
        pathfinder.mx 
Log Message:
- concurrent use of ws_newpage() and ws_newnids() that work with cheap freelist,
  and batch extends to the pre-bats, would under concurrent use be likely
  to extend multiple times unnecesarily, creating lot's of useless space.



Index: pathfinder.mx
===================================================================
RCS file: /cvsroot/monetdb/pathfinder/runtime/pathfinder.mx,v
retrieving revision 1.364
retrieving revision 1.365
diff -u -d -r1.364 -r1.365
--- pathfinder.mx       25 May 2007 00:16:59 -0000      1.364
+++ pathfinder.mx       25 May 2007 09:52:57 -0000      1.365
@@ -2766,7 +2766,14 @@
         err := CATCH(_shredlock_set(colname, wsid));
         lock_unset(pf_short);
 
-        if (isnil(err)) {
+        page_id := [EMAIL PROTECTED]; 
+
+        # inside the shredlock. try again. maybe another query added the 
desired pages
+        lock_set(coll_shortlock);
+        err := CATCH(page_id := __runtime_newpage(runtime));
+        lock_unset(coll_shortlock);
+
+        if (isnil(err) and isnil(page_id)) {
             var rid_size  := ws.fetch(_RID_SIZE).find(cont);
             var rid_level := ws.fetch(_RID_LEVEL).find(cont);
             var rid_prop  := ws.fetch(_RID_PROP).find(cont);
@@ -2795,10 +2802,6 @@
             # create a new [nil,oid] bat with densely descending tail values, 
ending at new_pid
             var newpids := densebat(wrd(last_pid - 
new_pid)).seqbase(oid(new_pid)).reverse().seqbase(oid(nil)).access(BAT_WRITE).revert();
 # put in reverse order to give the pages out in order 
 
-            lock_set(pf_short);
-            err := CATCH(_shredlock_unset(colname, wsid));
-            lock_unset(pf_short);
-
             # add extra created pages to the freelist
             if (isnil(err)) {
                 lock_set(coll_shortlock);
@@ -2806,6 +2809,11 @@
                 lock_unset(coll_shortlock);
             }
         }
+        if (isnil(err)) {
+            lock_set(pf_short);
+            err := CATCH(_shredlock_unset(colname, wsid));
+            lock_unset(pf_short);
+        }
     }
     if (not(isnil(err))) ERROR("ws_newpage: " + err);
     return page_id;
@@ -2853,31 +2861,41 @@
         err := CATCH(_shredlock_set(colname, wsid));
         lock_unset(pf_short);
 
+        var delta := empty_bat;
+ 
+        # inside the shredlock. try again. maybe another query added the 
desired nids
+        lock_set(coll_shortlock);
+        err := CATCH(delta := __runtime_newnids(runtime, cnt));
+        lock_unset(coll_shortlock);
+
         if (isnil(err)) {
-            var nid_rid := ws.fetch(_NID_RID).find(cont);
-            var nid_off := count(nid_rid);
-            var nid_cnt;
+            newnids.access(BAT_WRITE).append(delta);
+            if (bit(cnt :-= count(delta))) {
+                var nid_rid := ws.fetch(_NID_RID).find(cont);
+                var nid_off := count(nid_rid);
+                var nid_cnt;
 
-            coll_lock_set(ws, cont, COLL_SHORTLOCK, "ws_newnids"); 
-            var ws_logtime := usec(); 
-            pf_assert(CATCH(nid_cnt := __ws_newnids(nid_rid, cnt)), "master 
update failed (newnids)");
-            coll_lock_unset(ws, cont, COLL_SHORTLOCK, "ws_newnids", 
ws_logtime); 
+                coll_lock_set(ws, cont, COLL_SHORTLOCK, "ws_newnids"); 
+                var ws_logtime := usec(); 
+                pf_assert(CATCH(nid_cnt := __ws_newnids(nid_rid, cnt)), 
"master update failed (newnids)");
+                coll_lock_unset(ws, cont, COLL_SHORTLOCK, "ws_newnids", 
ws_logtime); 
 
-            # put nids in reverse order in the freelist, so they are given out 
in order
-            
newnids.access(BAT_WRITE).append(reverse(nid_rid.slice(nid_off,(nid_off :+= 
cnt) - 1)));
-            var delta := reverse(nid_rid.slice(nid_off,nid_cnt - 1));
-            delta := delta.copy().access(BAT_WRITE).revert(); 
+                # put nids in reverse order in the freelist, so they are given 
out in order
+                newnids.append(reverse(nid_rid.slice(nid_off,(nid_off :+= cnt) 
- 1)));
+                delta := reverse(nid_rid.slice(nid_off,nid_cnt - 
1)).copy().access(BAT_WRITE).revert(); 
 
+                if (nid_cnt > nid_off) {
+                    # add extra created NIDs to the freelist
+                    lock_set(coll_shortlock);
+                    err := 
CATCH(reverse(runtime.fetch(RT_NID_FREELIST)).append(delta));
+                    lock_unset(coll_shortlock);
+                }
+            }
+        }
+        if (isnil(err)) {
             lock_set(pf_short);
             err := CATCH(_shredlock_unset(colname, wsid));
             lock_unset(pf_short);
-
-            if (isnil(err) and (nid_cnt > nid_off)) {
-                # add extra created NIDs to the freelist
-                lock_set(coll_shortlock);
-                err := 
CATCH(reverse(runtime.fetch(RT_NID_FREELIST)).append(delta));
-                lock_unset(coll_shortlock);
-            }
         }
     }
     if (not(isnil(err))) ERROR("ws_newpage: " + err);


-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Monetdb-pf-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/monetdb-pf-checkins

Reply via email to