Changeset: ba4e331f2c4b for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=ba4e331f2c4b
Modified Files:
clients/R/Tests/dbi.R
clients/R/Tests/dbi.stable.out
configure.ag
gdk/gdk_utils.c
monetdb5/extras/rapi/rapi.R
monetdb5/extras/rapi/rapi.c
monetdb5/optimizer/opt_pipes.c
sql/backends/monet5/Tests/All
Branch: default
Log Message:
merged
diffs (truncated from 2216 to 300 lines):
diff --git a/clients/R/Tests/dbi.R b/clients/R/Tests/dbi.R
--- a/clients/R/Tests/dbi.R
+++ b/clients/R/Tests/dbi.R
@@ -152,7 +152,6 @@ dbWriteTable(conn,tname,mtcars,append=T,
stopifnot(identical(as.integer(2*nrow(mtcars)),tsize(conn,tname)))
dbRemoveTable(conn,tname)
-dbRemoveTable(conn,tname)
dbWriteTable(conn,tname,mtcars,append=F,overwrite=F,insert=T)
dbRemoveTable(conn,tname)
diff --git a/clients/R/Tests/dbi.stable.out b/clients/R/Tests/dbi.stable.out
--- a/clients/R/Tests/dbi.stable.out
+++ b/clients/R/Tests/dbi.stable.out
@@ -62,7 +62,6 @@ Ready.
[1] TRUE
[1] TRUE
[1] TRUE
-[1] FALSE
[1] TRUE
[1] TRUE
[1] TRUE
diff --git a/configure.ag b/configure.ag
--- a/configure.ag
+++ b/configure.ag
@@ -3393,6 +3393,9 @@ AC_SUBST(Erundir)
Qlibdir="$libdir"
Xlibdir="`$translatepath "$libdir"`"
QXlibdir="`echo "$Xlibdir" | sed 's/\\\\/\\\\\\\\/g'`"
+Elibdir="`echo "$Xlibdir" | sed 's/{exec_prefix}/{prefix}/'`"
+eval "Elibdir=${Elibdir}"
+QElibdir="`echo "$Elibdir" | sed 's/\\\\/\\\\\\\\/g'`"
AC_SUBST(Qlibdir)
AC_SUBST(Xlibdir)
AC_SUBST(QXlibdir)
@@ -3469,6 +3472,7 @@ AC_SUBST(QXSOURCE)
AC_DEFINE_UNQUOTED(LOCALSTATEDIR,"$QElocalstatedir",[modifiable single-machine
data])
AC_DEFINE_UNQUOTED(DATA_DIR,"$QEdatadir",[read-only architecture-independent
data])
AC_DEFINE_UNQUOTED(BINDIR,"$QEbindir",[location where binaries are installed])
+AC_DEFINE_UNQUOTED(LIBDIR,"$QElibdir",[location where libraries are installed])
dnl On Solaris, libxml2 enables threading only when _REENTRANT, __MT__
dnl or _POSIX_C_SOURCE >= 199506L is defined. The latter is only
diff --git a/gdk/gdk_utils.c b/gdk/gdk_utils.c
--- a/gdk/gdk_utils.c
+++ b/gdk/gdk_utils.c
@@ -421,6 +421,1056 @@ MT_init(void)
#endif
}
+/*
+ * @+ Session Initialization
+ * The interface code to the operating system is highly dependent on
+ * the processing environment. It can be filtered away with
+ * compile-time flags. Suicide is necessary due to some system
+ * implementation errors.
+ *
+ * The kernel requires file descriptors for I/O with the user. They
+ * are thread specific and should be obtained by a function.
+ *
+ * The arguments relevant for the kernel are extracted from the list.
+ * Their value is turned into a blanc space.
+ */
+
+#define CATNAP 50 /* time to sleep in ms for catnaps */
+
+static MT_Id GDKvmtrim_id;
+
+static void
+GDKvmtrim(void *limit)
+{
+ int highload = 0;
+ ssize_t prevmem = 0, prevrss = 0;
+
+ (void) limit;
+
+ do {
+ int t;
+ size_t rss;
+ ssize_t rssdiff, memdiff;
+ size_t cursize;
+
+ /* sleep using catnaps so we can exit in a timely fashion */
+ for (t = highload ? 500 : 5000; t > 0; t -= CATNAP) {
+ MT_sleep_ms(CATNAP);
+ if (GDKexiting())
+ return;
+ }
+ rss = MT_getrss();
+ rssdiff = (ssize_t) rss - (ssize_t) prevrss;
+ cursize = GDKvm_cursize();
+ memdiff = (ssize_t) cursize - (ssize_t) prevmem;
+ MEMDEBUG fprintf(stderr, "alloc = " SZFMT " %+zd rss = " SZFMT
" %+zd\n", cursize, memdiff, rss, rssdiff);
+ prevmem = cursize;
+ prevrss = rss;
+ if (memdiff >= 0 && rssdiff < -32 * (ssize_t) MT_pagesize()) {
+ BBPtrim(rss);
+ highload = 1;
+ } else {
+ highload = 0;
+ }
+ } while (!GDKexiting());
+}
+
+static void THRinit(void);
+static void GDKlockHome(void);
+
+int
+GDKinit(opt *set, int setlen)
+{
+ char *dbpath = mo_find_option(set, setlen, "gdk_dbpath");
+ char *p;
+ opt *n;
+ int i, nlen = 0;
+ char buf[16];
+
+ /* some sanity checks (should also find if symbols are not defined) */
+ assert(sizeof(char) == SIZEOF_CHAR);
+ assert(sizeof(short) == SIZEOF_SHORT);
+ assert(sizeof(int) == SIZEOF_INT);
+ assert(sizeof(long) == SIZEOF_LONG);
+ assert(sizeof(lng) == SIZEOF_LNG);
+#ifdef HAVE_HGE
+ assert(sizeof(hge) == SIZEOF_HGE);
+#endif
+ assert(sizeof(oid) == SIZEOF_OID);
+ assert(sizeof(void *) == SIZEOF_VOID_P);
+ assert(sizeof(size_t) == SIZEOF_SIZE_T);
+ assert(sizeof(ptrdiff_t) == SIZEOF_PTRDIFF_T);
+ assert(SIZEOF_OID == SIZEOF_INT || SIZEOF_OID == SIZEOF_LNG);
+
+#ifdef NEED_MT_LOCK_INIT
+ MT_lock_init(&MT_system_lock,"MT_system_lock");
+ ATOMIC_INIT(GDKstoppedLock);
+ ATOMIC_INIT(mbyteslock);
+ MT_lock_init(&GDKnameLock, "GDKnameLock");
+ MT_lock_init(&GDKthreadLock, "GDKthreadLock");
+ MT_lock_init(&GDKtmLock, "GDKtmLock");
+#endif
+ for (i = 0; i <= BBP_BATMASK; i++) {
+ MT_lock_init(&GDKbatLock[i].swap, "GDKswapLock");
+ MT_lock_init(&GDKbatLock[i].hash, "GDKhashLock");
+ MT_lock_init(&GDKbatLock[i].imprints, "GDKimprintsLock");
+ }
+ for (i = 0; i <= BBP_THREADMASK; i++) {
+ MT_lock_init(&GDKbbpLock[i].alloc, "GDKcacheLock");
+ MT_lock_init(&GDKbbpLock[i].trim, "GDKtrimLock");
+ GDKbbpLock[i].free = 0;
+ }
+ errno = 0;
+ if (!GDKenvironment(dbpath))
+ return 0;
+
+ if ((p = mo_find_option(set, setlen, "gdk_debug")))
+ GDKdebug = strtol(p, NULL, 10);
+
+ if (mnstr_init() < 0)
+ return 0;
+ MT_init_posix();
+ THRinit();
+#ifndef NATIVE_WIN32
+ BATSIGinit();
+#endif
+#ifdef WIN32
+ (void) signal(SIGABRT, BATSIGabort);
+#ifndef __MINGW32__ // MinGW does not have these
+ _set_abort_behavior(0, _CALL_REPORTFAULT | _WRITE_ABORT_MSG);
+ _set_error_mode(_OUT_TO_STDERR);
+#endif
+#endif
+ /* now try to lock the database */
+ GDKlockHome();
+
+ /* Mserver by default takes 80% of all memory as a default */
+ GDK_mem_maxsize = (size_t) ((double) MT_npages() * (double)
MT_pagesize() * 0.815);
+ BBPinit();
+
+ n = (opt *) malloc(setlen * sizeof(opt));
+ for (i = 0; i < setlen; i++) {
+ int done = 0;
+ int j;
+
+ for (j = 0; j < nlen; j++) {
+ if (strcmp(n[j].name, set[i].name) == 0) {
+ if (n[j].kind < set[i].kind) {
+ n[j] = set[i];
+ }
+ done = 1;
+ break;
+ }
+ }
+ if (!done) {
+ n[nlen] = set[i];
+ nlen++;
+ }
+ }
+ /* check some options before creating our first BAT */
+ for (i = 0; i < nlen; i++) {
+ if (strcmp("gdk_mem_maxsize", n[i].name) == 0) {
+ GDK_mem_maxsize = (size_t) strtoll(n[i].value, NULL,
10);
+ GDK_mem_maxsize = MAX(1 << 26, GDK_mem_maxsize);
+ } else if (strcmp("gdk_vm_maxsize", n[i].name) == 0) {
+ GDK_vm_maxsize = (size_t) strtoll(n[i].value, NULL, 10);
+ GDK_vm_maxsize = MAX(1 << 30, GDK_vm_maxsize);
+ } else if (strcmp("gdk_mmap_minsize", n[i].name) == 0) {
+ GDK_mmap_minsize = (size_t) strtoll(n[i].value, NULL,
10);
+ } else if (strcmp("gdk_mmap_pagesize", n[i].name) == 0) {
+ GDK_mmap_pagesize = (size_t) strtoll(n[i].value, NULL,
10);
+ if (GDK_mmap_pagesize < 1 << 12 ||
+ GDK_mmap_pagesize > 1 << 20 ||
+ /* x & (x - 1): turn off rightmost 1 bit;
+ * i.e. if result is zero, x is power of
+ * two */
+ (GDK_mmap_pagesize & (GDK_mmap_pagesize - 1)) != 0)
+ GDKfatal("GDKinit: gdk_mmap_pagesize must be
power of 2 between 2**12 and 2**20\n");
+ }
+ }
+
+ GDKkey = BATnew(TYPE_void, TYPE_str, 100, TRANSIENT);
+ GDKval = BATnew(TYPE_void, TYPE_str, 100, TRANSIENT);
+ if (GDKkey == NULL || GDKval == NULL) {
+ /* no cleanup necessary before GDKfatal */
+ GDKfatal("GDKinit: Could not create environment BAT");
+ }
+ BATseqbase(GDKkey,0);
+ BATkey(GDKkey, BOUND2BTRUE);
+ BATrename(GDKkey, "environment_key");
+
+ BATseqbase(GDKval,0);
+ BATkey(GDKval, BOUND2BTRUE);
+ BATrename(GDKval, "environment_val");
+
+ /* store options into environment BATs */
+ for (i = 0; i < nlen; i++)
+ GDKsetenv(n[i].name, n[i].value);
+ free(n);
+
+ GDKnr_threads = GDKgetenv_int("gdk_nr_threads", 0);
+ if (GDKnr_threads == 0)
+ GDKnr_threads = MT_check_nr_cores();
+
+ if ((p = GDKgetenv("gdk_dbpath")) != NULL &&
+ (p = strrchr(p, DIR_SEP)) != NULL) {
+ GDKsetenv("gdk_dbname", p + 1);
+#if DIR_SEP != '/' /* on Windows look for different separator */
+ } else if ((p = GDKgetenv("gdk_dbpath")) != NULL &&
+ (p = strrchr(p, '/')) != NULL) {
+ GDKsetenv("gdk_dbname", p + 1);
+#endif
+ }
+ if (GDKgetenv("gdk_vm_maxsize") == NULL) {
+ snprintf(buf, sizeof(buf), SZFMT, GDK_vm_maxsize);
+ GDKsetenv("gdk_vm_maxsize", buf);
+ }
+ if (GDKgetenv("gdk_mem_maxsize") == NULL) {
+ snprintf(buf, sizeof(buf), SZFMT, GDK_mem_maxsize);
+ GDKsetenv("gdk_mem_maxsize", buf);
+ }
+ if (GDKgetenv("gdk_mmap_minsize") == NULL) {
+ snprintf(buf, sizeof(buf), SZFMT, GDK_mmap_minsize);
+ GDKsetenv("gdk_mmap_minsize", buf);
+ }
+ if (GDKgetenv("gdk_mmap_pagesize") == NULL) {
+ snprintf(buf, sizeof(buf), SZFMT, GDK_mmap_pagesize);
+ GDKsetenv("gdk_mmap_pagesize", buf);
+ }
+ if (GDKgetenv("monet_pid") == NULL) {
+ snprintf(buf, sizeof(buf), "%d", (int) getpid());
+ GDKsetenv("monet_pid", buf);
+ }
+
+ /* only start vmtrim thread when explicitly asked to do so or
+ * when on a 32 bit architecture and not told to not start
+ * it;
+ * see also mo_builtin_settings() in common/options/monet_options.c
+ */
+ p = mo_find_option(set, setlen, "gdk_vmtrim");
+ if (
+#if SIZEOF_VOID_P == 4
+ /* 32 bit architecture */
+ p == NULL || /* default is yes */
+#else
+ /* 64 bit architecture */
+ p != NULL && /* default is no */
+#endif
+ strcasecmp(p, "yes") == 0)
+ MT_create_thread(&GDKvmtrim_id, GDKvmtrim, &GDK_mem_maxsize,
+ MT_THR_JOINABLE);
+
+ return 1;
+}
+
+int GDKnr_threads = 0;
+static int GDKnrofthreads;
+
+int
+GDKexiting(void)
+{
+ int stopped;
+#ifdef ATOMIC_LOCK
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list