Changeset: ae75e29b714f for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=ae75e29b714f
Modified Files:
        gdk/ChangeLog.Feb2013
        gdk/gdk.h
        gdk/gdk_storage.c
        monetdb5/mal/mal_authorize.c
        monetdb5/mal/mal_interpreter.c
Branch: default
Log Message:

Merge with Feb2013 branch.


diffs (truncated from 339 to 300 lines):

diff --git a/gdk/ChangeLog.Feb2013 b/gdk/ChangeLog.Feb2013
--- a/gdk/ChangeLog.Feb2013
+++ b/gdk/ChangeLog.Feb2013
@@ -1,3 +1,8 @@
 # ChangeLog file for MonetDB
 # This file is updated with Maddlog
 
+* Tue May  7 2013 Sjoerd Mullender <[email protected]>
+- System calls to flush files to disks were added.  This may cause
+  some slowdown, but it should provide better durability, especially
+  in the face of power failures.
+
diff --git a/gdk/gdk.h b/gdk/gdk.h
--- a/gdk/gdk.h
+++ b/gdk/gdk.h
@@ -1770,6 +1770,12 @@ gdk_export void GDKqsort_rev(void *h, vo
                        if ((b)->batCount == 0) {                       \
                                (col)->nonil = 1;                       \
                                (col)->nil = 0;                         \
+                               if (!(col)->dense &&                    \
+                                   (col)->type == TYPE_oid) {          \
+                                       (col)->dense = 1;               \
+                                       (col)->seq = 0;                 \
+                                       (b)->batDirtydesc = 1;          \
+                               }                                       \
                        } else if (!(col)->dense &&                     \
                                   (col)->type == TYPE_oid &&           \
                                   (sqbs = ((oid *) 
(col)->heap.base)[(b)->batFirst]) != oid_nil) { \
diff --git a/gdk/gdk_storage.c b/gdk/gdk_storage.c
--- a/gdk/gdk_storage.c
+++ b/gdk/gdk_storage.c
@@ -324,6 +324,24 @@ GDKsave(const char *nme, const char *ext
                }
        }
        if (fd >= 0) {
+               if (
+#ifdef NATIVE_WIN32
+                       _commit(fd) < 0
+#else
+#ifdef HAVE_FDATASYNC
+                       fdatasync(fd) < 0
+#else
+#ifdef HAVE_FSYNC
+                       fsync(fd) < 0
+#else
+                       0
+#endif
+#endif
+#endif
+                       ) {
+                       GDKsyserror("GDKsave: error on: name=%s, ext=%s, 
mode=%d\n", nme, ext ? ext : "", (int) mode);
+                       err = -1;
+               }
                err |= close(fd);
                if (err && GDKunlink(BATDIR, nme, ext)) {
                        /* do not tolerate corrupt heap images
diff --git a/monetdb5/mal/mal_authorize.c b/monetdb5/mal/mal_authorize.c
--- a/monetdb5/mal/mal_authorize.c
+++ b/monetdb5/mal/mal_authorize.c
@@ -185,7 +185,7 @@ AUTHinitTables(void) {
                        return msg;
                if (uid != 0)
                        throw(MAL, "initTables", INTERNAL_AUTHORIZATION " while 
they were just created!");
-               AUTHcommit();
+               /* normally, we'd commit here, but it's done already in 
AUTHaddUser */
        }
 
        return(MAL_SUCCEED);
diff --git a/monetdb5/mal/mal_interpreter.c b/monetdb5/mal/mal_interpreter.c
--- a/monetdb5/mal/mal_interpreter.c
+++ b/monetdb5/mal/mal_interpreter.c
@@ -3,14 +3,14 @@
  * Version 1.1 (the "License"); you may not use this file except in
  * compliance with the License. You may obtain a copy of the License at
  * http://www.monetdb.org/Legal/MonetDBLicense
- * 
+ *
  * Software distributed under the License is distributed on an "AS IS"
  * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
  * License for the specific language governing rights and limitations
  * under the License.
- * 
+ *
  * The Original Code is the MonetDB Database System.
- * 
+ *
  * The Initial Developer of the Original Code is CWI.
  * Portions created by CWI are Copyright (C) 1997-July 2008 CWI.
  * Copyright August 2008-2013 MonetDB B.V.
@@ -84,7 +84,7 @@ void showErrors(Client cntxt)
 str malCommandCall(MalStkPtr stk, InstrPtr pci)
 {
        str ret= MAL_SUCCEED;
-       
+
        switch (pci->argc) {
        case 0: ret = (str)(*pci->fcn)();
                break;
@@ -322,20 +322,21 @@ str runMAL(Client cntxt, MalBlkPtr mb, M
                if (cntxt->itrace == 0) /* permit debugger analysis */
                        throw( MAL, "mal.interpreter", "Syntax error in 
script");
        }
-/*
- * Prepare a new interpreter call. This involves two steps, (1) allocate
- * the minimum amount of stack space needed, some slack resources
- * are included to permit code optimizers to add a few variables at run time,
- * (2) copying the arguments into the new stack frame.
- *
- * The env stackframe is set when a MAL function is called recursively.
- * Alternatively, there is no caller but a stk to be re-used for 
interpretation.
- * We assume here that it aligns with the variable table of the routine
- * being called.
- *
- * allocate space for value stack
- * the global stack should be large enough
-*/
+
+       /* Prepare a new interpreter call. This involves two steps, (1)
+        * allocate the minimum amount of stack space needed, some slack
+        * resources are included to permit code optimizers to add a few
+        * variables at run time, (2) copying the arguments into the new
+        * stack frame.
+        *
+        * The env stackframe is set when a MAL function is called
+        * recursively.  Alternatively, there is no caller but a stk to be
+        * re-used for interpretation.  We assume here that it aligns with
+        * the variable table of the routine being called.
+        *
+        * allocate space for value stack the global stack should be large
+        * enough
+        */
        if (env != NULL) {
                stk = env;
                if (mb != stk->blk)
@@ -360,13 +361,14 @@ str runMAL(Client cntxt, MalBlkPtr mb, M
                                /* we are running low on stack space */
                                throw(MAL, "mal.interpreter", MAL_STACK_FAIL);
                }
-/*
- * An optimization is to copy all constant variables used in functions 
immediately
- * onto the value stack. Then we do not have to check for their location
- * later on any more. At some point, the effect is optimal, if at least several
- * constants are referenced in a function (a gain on tst400a of 20% has been
- * observed due the small size of the function).
- */
+               /*
+                * An optimization is to copy all constant variables used in
+                * functions immediately onto the value stack. Then we do not
+                * have to check for their location later on any more. At some
+                * point, the effect is optimal, if at least several constants
+                * are referenced in a function (a gain on tst400a of 20% has
+                * been observed due the small size of the function).
+                */
        }
        if (stk->cmd && env && stk->cmd != 'f')
                stk->cmd = env->cmd;
@@ -427,11 +429,12 @@ callMAL(Client cntxt, MalBlkPtr mb, MalS
        ValPtr lhs;
        InstrPtr pci = getInstrPtr(mb, 0);
  
-/*
- * Control the level of parallelism. The maximum number of concurrent MAL plans
- * is determined by an environment variable. It is initially set equal to the
- * number of cores, which may be too coarse.
- */
+       /*
+        * Control the level of parallelism. The maximum number of
+        * concurrent MAL plans is determined by an environment
+        * variable. It is initially set equal to the number of cores,
+        * which may be too coarse.
+        */
        MT_sema_down(&mal_parallelism,"callMAL");
 #ifdef DEBUG_CALLMAL
        mnstr_printf(cntxt->fdout, "callMAL\n");
@@ -477,11 +480,11 @@ callMAL(Client cntxt, MalBlkPtr mb, MalS
 }
 
 /*
- * The core of the interpreter is presented next. It takes the context 
information
- * and starts the interpretation at the designated instruction.
- * Note that the stack frame is aligned and initialized in the enclosing 
routine.
- * When we start executing the first instruction, we take the wall-clock time 
for
- * resource management.
+ * The core of the interpreter is presented next. It takes the context
+ * information and starts the interpretation at the designated
+ * instruction.  Note that the stack frame is aligned and initialized
+ * in the enclosing routine.  When we start executing the first
+ * instruction, we take the wall-clock time for resource management.
  */
 str runMALsequence(Client cntxt, MalBlkPtr mb, int startpc,
                                   int stoppc, MalStkPtr stk, MalStkPtr env, 
InstrPtr pcicaller)
@@ -547,23 +550,26 @@ str runMALsequence(Client cntxt, MalBlkP
                if (pci->recycle > 0)
                        clk = GDKms();
                if (!RECYCLEentry(cntxt, mb, stk, pci)){
-/* The interpreter loop
- * The interpreter is geared towards execution a MAL procedure together
- * with all its decendant invocations. As such, it provides the
- * MAL abtract machine processor.
- *
- * The value-stack frame of the surrounding scope is needed to resolve
- * binding values.  Getting (putting) a value from (into) a surrounding
- * scope should be guarded with the exclusive access lock.
- * This situation is encapsulated by a bind() function call, whose parameters
- * contain the access mode required.
- *
- * The formal procedure arguments are assumed to always occupy the first
- * elements in the value stack.
- *
- * Before we execute an instruction the variables to be garbage collected
- * are identified. In the post-execution phase they are removed.
- */
+                       /* The interpreter loop
+                        * The interpreter is geared towards execution a MAL
+                        * procedure together with all its decendant
+                        * invocations. As such, it provides the MAL abtract
+                        * machine processor.
+                        *
+                        * The value-stack frame of the surrounding scope is
+                        * needed to resolve binding values.  Getting (putting) 
a
+                        * value from (into) a surrounding scope should be 
guarded
+                        * with the exclusive access lock.  This situation is
+                        * encapsulated by a bind() function call, whose
+                        * parameters contain the access mode required.
+                        *
+                        * The formal procedure arguments are assumed to always
+                        * occupy the first elements in the value stack.
+                        *
+                        * Before we execute an instruction the variables to be
+                        * garbage collected are identified. In the 
post-execution
+                        * phase they are removed.
+                        */
                        if (garbageControl(pci)) {
                                for (i = 0; i < pci->argc; i++) {
                                        int a = getArg(pci, i);
@@ -591,19 +597,21 @@ str runMALsequence(Client cntxt, MalBlkP
                        ret = 0;
                        switch (pci->token) {
                        case ASSIGNsymbol:
-/* Assignment command
- * The assignment statement copies values around on the stack frame,
- * including multiple assignments.
- *
- * Pushing constants/initial values onto the stack is a separate operation.
- * It takes the constant value discovered at compile time and stored in the
- * symbol table and moves it to the stackframe location. This activity
- * is made part of the start-up procedure.
- *
- * The before after calls should be reconsidered here, because
- * their. They seem superflous and the way they are used will
- * cause errors in multi-assignment statements.
- */
+                               /* Assignment command
+                                * The assignment statement copies values 
around on
+                                * the stack frame, including multiple 
assignments.
+                                *
+                                * Pushing constants/initial values onto the 
stack is
+                                * a separate operation.  It takes the constant 
value
+                                * discovered at compile time and stored in the 
symbol
+                                * table and moves it to the stackframe 
location. This
+                                * activity is made part of the start-up 
procedure.
+                                *
+                                * The before after calls should be 
reconsidered here,
+                                * because their. They seem superflous and the 
way
+                                * they are used will cause errors in 
multi-assignment
+                                * statements.
+                                */
                                for (k = 0, i = pci->retc; k < pci->retc && i < 
pci->argc; i++, k++) {
                                        lhs = &stk->stk[pci->argv[k]];
                                        rhs = &stk->stk[pci->argv[i]];
@@ -625,11 +633,12 @@ str runMALsequence(Client cntxt, MalBlkP
                                ret =malCommandCall(stk, pci);
                                break;
                        case FACcall:
-/*
- * Factory calls are more involved. At this stage it is a synchrononous
- * call to the factory manager.
- * Factory calls should deal with the reference counting.
- */
+                               /*
+                                * Factory calls are more involved. At this 
stage it
+                                * is a synchrononous call to the factory 
manager.
+                                * Factory calls should deal with the reference
+                                * counting.
+                                */
                                if (pci->blk == NULL)
                                        ret = createScriptException(mb, stkpc, 
MAL, NULL,
                                                "reference to MAL function 
missing");
@@ -648,11 +657,12 @@ str runMALsequence(Client cntxt, MalBlkP
                                }
                                break;
                        case FCNcall:
-/*
- * MAL function calls are relatively expensive, because they have to assemble
- * a new stack frame and do housekeeping, such as garbagecollection of all
- * non-returned values.
- */
+                               /*
+                                * MAL function calls are relatively expensive,
+                                * because they have to assemble a new stack 
frame and
_______________________________________________
checkin-list mailing list
[email protected]
http://mail.monetdb.org/mailman/listinfo/checkin-list

Reply via email to