Changeset: abed75cbed36 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=abed75cbed36
Modified Files:
MonetDB5/configure.ag
MonetDB5/src/modules/mal/trader.mx
MonetDB5/src/optimizer/opt_octopus.mx
MonetDB5/src/optimizer/opt_prelude.mx
MonetDB5/src/scheduler/run_octopus.mx
sql/configure.ag
sql/src/backends/monet5/sql.mx
Branch: default
Log Message:
Major changes in octopus plan generation. Tentacle creation is based now on
clustering of instructions using the partitioned bats.
diffs (truncated from 1716 to 300 lines):
diff -r 1191ba5a95b6 -r abed75cbed36 MonetDB5/configure.ag
--- a/MonetDB5/configure.ag Thu Sep 16 13:20:25 2010 +0200
+++ b/MonetDB5/configure.ag Thu Sep 16 17:29:31 2010 +0200
@@ -313,57 +313,6 @@
AC_SUBST(SPHINXCLIENT_LIBS, $SPHINXCLIENT_LIBS)
AM_CONDITIONAL(HAVE_SPHINXCLIENT, test x"$have_sphinxclient" != xno)
-have_cfitsio="auto"
-AC_ARG_WITH(cfitsio,
- AS_HELP_STRING([--with-cfitsio=DIR],[cfitsio library is installed in DIR]),
- [have_cfitsio="$withval"], [have_cfitsio="auto"])
-if test "x$have_cfitsio" != xno; then
-
- CFITSIO_CONFIG=""
- XPATH="$PATH"
- case "$have_cfitsio" in
- auto|yes)
- ;;
- *)
- XPATH="$have_cfitsio/bin"
- ;;
- esac
-
- AC_PATH_PROG(CFITSIO_CONFIG,pkg-config,,$XPATH)
-
- if test "x$CFITSIO_CONFIG" != x; then
- if `$CFITSIO_CONFIG --exists cfitsio` ; then
- CFITSIO_CFLAGS="`$CFITSIO_CONFIG cfitsio --cflags`"
- CFITSIO_LIBS="`$CFITSIO_CONFIG cfitsio --libs`"
- fi
- else
- case "$have_cfitsio" in
- auto|yes)
- ;;
- *)
- CFITSIO_CFLAGS="-I$have_cfitsio/include/cfitsio"
- CFITSIO_LIBS="-L$have_cfitsio/lib -lcfitsio"
- ;;
- esac
- fi
-
- save_CPPFLAGS="$CPPFLAGS"
- save_LDFLAGS="$LDFLAGS"
- CPPFLAGS="$CPPFLAGS $CFITSIO_CFLAGS"
- LDFLAGS="$LDFLAGS $CFITSIO_LIBS"
- AC_CHECK_HEADER(fitsio.h,
- AC_CHECK_LIB(cfitsio, ffopen,
- AC_DEFINE(HAVE_CFITSIO, 1, [Define if you have the
cfitsio library])
- have_cfitsio=yes,
- [ if test "x$have_cfitsio" != xauto; then
AC_MSG_ERROR([-lcfitsio library not found]); fi; have_cfitsio=no ], "-lm"),
- [ if test "x$have_cfitsio" != xauto; then
AC_MSG_ERROR([fitsio.h header not found]); fi; have_cfitsio=no ])
- LDFLAGS="$save_LDFLAGS"
- CPPFLAGS="$save_CPPFLAGS"
-fi
-AC_SUBST(CFITSIO_CFLAGS, $CFITSIO_CFLAGS)
-AC_SUBST(CFITSIO_LIBS, $CFITSIO_LIBS)
-AM_CONDITIONAL(HAVE_CFITSIO, test x"$have_cfitsio" != xno)
-
dnl RIPEMD160 is patent free, academic and European, but unfortunately
dnl can't use it by default, as that would exclude JDBC usage (Java
dnl doesn't natively support RIPEMD160).
diff -r 1191ba5a95b6 -r abed75cbed36 MonetDB5/src/modules/mal/trader.mx
--- a/MonetDB5/src/modules/mal/trader.mx Thu Sep 16 13:20:25 2010 +0200
+++ b/MonetDB5/src/modules/mal/trader.mx Thu Sep 16 17:29:31 2010 +0200
@@ -36,6 +36,10 @@
address TRADERmakeBid
comment "Make a bid for execution of function octopus.<fnname>";
+pattern makeBids(bidtype:sht, fnname1:str...):lng...
+address TRADERmakeBids
+comment "Make execution bids for functions octopus.<fnname1>, ...";
+
@h
#ifndef _TRADER_
#define _TRADER_
@@ -229,4 +233,33 @@
return MAL_SUCCEED;
}
+str TRADERmakeBids(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci)
+{
+ lng *bid;
+ str fnname;
+ sht bidtype;
+ Symbol sym;
+ static str octopusRef = NULL;
+ int n = pci->argc - pci->retc -1;
+ int i;
+
+ (void) mb;
+
+ if (octopusRef == 0)
+ octopusRef = putName("octopus",7);
+
+ bidtype = *(sht *) getArgReference(stk,pci,pci->retc);
+ for ( i = 0; i < n ; i++){
+ fnname = *(str *) getArgReference(stk,pci,i + pci->retc + 1);
+ bid = (lng *) getArgReference(stk,pci,i);
+ sym = findSymbol(cntxt->nspace, octopusRef, fnname);
+ if ( sym == NULL)
+ throw(MAL,"trader.makeBids", RUNTIME_SIGNATURE_MISSING "%s",
fnname);
+
+ *bid = estimateSavings(sym->def, bidtype);
+ }
+
+ return MAL_SUCCEED;
+}
+
@}
diff -r 1191ba5a95b6 -r abed75cbed36 MonetDB5/src/optimizer/opt_octopus.mx
--- a/MonetDB5/src/optimizer/opt_octopus.mx Thu Sep 16 13:20:25 2010 +0200
+++ b/MonetDB5/src/optimizer/opt_octopus.mx Thu Sep 16 17:29:31 2010 +0200
@@ -177,6 +177,17 @@
#include "mal_interpreter.h" /* for showErrors() */
#include "mal_builder.h"
#include "mal_sabaoth.h"
+#include "mal_recycle.h"
+
+typedef struct MALPART {
+ str sch;
+ str tab;
+ oid low;
+ oid hgh;
+ int *ret;
+ int retcnt;
+} MalPart, *MalPartPtr;
+
@-
The algorithm consists of several steps. The first one
replaces the original query and creates the tentacle
@@ -192,6 +203,65 @@
static lng octopusSeq = 0;
sht bidStrategy = 1;
+static MalPartPtr octCluster = NULL;
+static int octClCnt = 0;
+
+static void
+OCTinitMalPart()
+{
+ if ( octClCnt ){
+ int i;
+ for (i = 0; i < octClCnt; i++){
+ GDKfree(octCluster[i].sch);
+ GDKfree(octCluster[i].tab);
+ GDKfree(octCluster[i].ret);
+ }
+ GDKfree(octCluster);
+ }
+ octCluster = (MalPartPtr) GDKzalloc( sizeof(MalPart) * 1000);
+ octClCnt = 0;
+}
+
+static int
+OCTgetMalPart(str sch, str tab, oid low, oid hgh)
+{
+ int i;
+
+ for (i = 0; i < octClCnt; i++)
+ if ( strcmp(tab, octCluster[i].tab) == 0 &&
+ low == octCluster[i].low && hgh ==
octCluster[i].hgh )
+ break;
+ if ( i < octClCnt )
+ return i;
+ octCluster[i].sch = GDKstrdup(sch);
+ octCluster[i].tab = GDKstrdup(tab);
+ octCluster[i].low = low;
+ octCluster[i].hgh = hgh;
+ octCluster[i].ret = (int*) GDKzalloc( sizeof(int) * 20);
+ octCluster[i].retcnt = 0;
+ octClCnt++;
+ return i;
+}
+
+static void
+OCTaddResult(int cl, int residx)
+{
+ MalPartPtr c;
+ if ( cl <= 0 || cl >= octClCnt ) {
+ mnstr_printf(GDKout, "Illegal instruction partition index \n");
+ return;
+ }
+ c = &octCluster[cl];
+ if ( c->retcnt < 20 ){
+ c->ret[c->retcnt++] = residx;
+ }
+ else {
+ mnstr_printf(GDKout, "No room for more results \n");
+ return;
+ }
+
+}
+
static int
OCTinitcode(Client cntxt, MalBlkPtr mb){
InstrPtr p;
@@ -219,232 +289,637 @@
Beware, exceptions should be catched and thrown after the
connection has been closed.
@c
-static void
-OCTexitcode(MalBlkPtr mb, int conn, int varid)
+
+static int
+getJoinPathType(MalBlkPtr mb, InstrPtr p)
{
- InstrPtr p;
+ int tpe;
+ int ht, tt;
- newCatchStmt(mb, "ANYexception");
- p = newStmt(mb, remoteRef, disconnectRef);
- pushArgument(mb, p, conn);
- newRaiseStmt(mb, "ANYexception");
- newExitStmt(mb, "ANYexception");
-
- p = newStmt(mb, remoteRef, disconnectRef);
- pushArgument(mb, p, conn);
- p = newAssignment(mb);
- getArg(p, 0) = getArg(getInstrPtr(mb, 0), 0);
- pushArgument(mb, p, varid);
- p->barrier = RETURNsymbol;
- pushEndInstruction(mb);
- p = newStmt(mb, optimizerRef, putName("aliases", 7));
- p = pushStr(mb, p, octopusRef);
- p = pushStr(mb, p, getFunctionId(getInstrPtr(mb, 0)));
+ if ( p->argc < 3)
+ return TYPE_any;
+ if ( !isaBatType(getArgType(mb,p,1)) ||
+ !isaBatType(getArgType(mb,p,p->argc-1)))
+ return TYPE_any;
+ ht = getHeadType(getArgType(mb,p,1));
+ tt = getTailType(getArgType(mb,p,p->argc-1));
+ tpe = newBatType(ht,tt);
+ return tpe;
}
-static MalBlkPtr
-OPTtentacle(Client cntxt, MalBlkPtr mb, InstrPtr *old, InstrPtr pci, int
start, int idx, int v2, int *wvar, int *tnm, int *res){
- MalBlkPtr tm = NULL;
- InstrPtr p = NULL, q = NULL, sig = old[0];
- int varid= pci->argv[idx],i,j,top=0, fnd;
+static MalBlkPtr
+OCTnewTentacle(Client cntxt, MalBlkPtr mb, bte tidx, int v2, bte *cl)
+{
+ Symbol s;
+ MalBlkPtr tmb;
+ MalPartPtr ocl;
+ InstrPtr p, tp, sig = mb->stmt[0], tsig;
char buf[BUFSIZ];
- InstrPtr *list = (InstrPtr*) GDKzalloc(sizeof(InstrPtr) * mb->ssize);
- char *needed= (char*) GDKzalloc(mb->vtop);
int *alias= (int*) GDKzalloc(mb->vtop * sizeof(int));
- str name= NULL, name2= NULL;
- Symbol s;
-/* ValRecord cst; */
- int conn=0, tidx=idx-1;
+ int i, j, k, conn, last, tpe;
+ str nm;
- /* check if the head is properly administered for Octopus */
- SABAOTHgetLocalConnection(&name);
+ ocl = &octCluster[tidx];
- if ( name == NULL || *name == 0 || list == NULL || needed == NULL){
- if ( list ) GDKfree(list);
- if ( needed) GDKfree(needed);
- if ( alias) GDKfree(alias);
- if ( name) GDKfree(name);
- return 0;
- }
+ snprintf(buf,BUFSIZ,"tentacle_"LLFMT"_%d", mb->legid,tidx);
+ nm = putName(buf,strlen(buf));
+ s = newFunction(octopusRef,nm,FUNCTIONsymbol);
+ tmb = s->def;
+ tmb->keephistory= mb->keephistory;
- OPTDEBUGoctopus {
- mnstr_printf(cntxt->fdout,"#create tentacle for %d %d
%d\n",start,idx,varid);
- printInstruction(cntxt->fdout,mb,0,pci,0);
- }
-
- /* locate the last assignment for varid */
- fnd = -1;
- for (i = start; i > 0; i--){
-/* p= getInstrPtr(mb,i); */
- p = old[i];
- for (j=0; j<p->retc; j++)
- if ( getArg(p,j) == varid){
- fnd= j;
- goto foundit;
- }
- }
-foundit:
- if ( p == NULL) {
- if ( list ) GDKfree(list);
- if ( needed) GDKfree(needed);
- if ( alias) GDKfree(alias);
- return 0; /* bail out, internal error */
- }
_______________________________________________
Checkin-list mailing list
[email protected]
http://mail.monetdb.org/mailman/listinfo/checkin-list