Changeset: 36f6ce87b64b for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=36f6ce87b64b
Modified Files:
clients/Tests/exports.stable.out
clients/mapiclient/tomograph.c
gdk/gdk_heap.c
gdk/gdk_utils.c
monetdb5/optimizer/opt_dataflow.c
monetdb5/optimizer/opt_dataflow.h
sql/backends/monet5/datacell/datacell.c
sql/backends/monet5/datacell/opt_datacell.c
sql/backends/monet5/datacell/opt_datacell.h
sql/backends/monet5/sql_scenario.c
Branch: default
Log Message:
Merge with Feb2013 branch.
diffs (truncated from 545 to 300 lines):
diff --git a/clients/Tests/exports.stable.out b/clients/Tests/exports.stable.out
--- a/clients/Tests/exports.stable.out
+++ b/clients/Tests/exports.stable.out
@@ -2644,7 +2644,6 @@ str getExceptionPlace(str);
enum malexception getExceptionType(str);
Scenario getFreeScenario(void);
Symbol getFunctionSymbol(Module scope, InstrPtr p);
-int getGDKType(int tpe);
char **getHelp(Module m, str pat, int flag);
char **getHelpMatch(char *pat);
MalBlkPtr getMalBlkHistory(MalBlkPtr mb, int idx);
@@ -2812,6 +2811,7 @@ MT_Lock mal_delayLock;
void mal_exit(void);
int mal_init(void);
MT_Lock mal_namespaceLock;
+MT_Sema mal_parallelism;
MT_Lock mal_profileLock;
str mal_quote(const char *msg, size_t size);
MT_Lock mal_remoteLock;
@@ -3036,7 +3036,7 @@ void releaseBAT(MalBlkPtr mb, MalStkPtr
int releaseBox(Box box, str name);
str remapRef;
str remoteRef;
-void removeDataflow(InstrPtr *old, int limit);
+void removeDataflow(Client cntxt, MalBlkPtr mb);
void removeInstruction(MalBlkPtr mb, InstrPtr p);
void removeInstructionBlock(MalBlkPtr mb, int pc, int cnt);
int removeProp;
diff --git a/clients/mapiclient/tomograph.c b/clients/mapiclient/tomograph.c
--- a/clients/mapiclient/tomograph.c
+++ b/clients/mapiclient/tomograph.c
@@ -1307,13 +1307,20 @@ static void scandata(char *filename)
starttime = 0;
while (!feof(f)) {
+ int x;
if ( fgets(line,2 * BUFSIZ,f) == NULL) {
fprintf(stderr, "scandata read error\n");
}
- sscanf(line,
"%d\t"LLFMT"\t"LLFMT"\t"LLFMT"\t"LLFMT"\t"LLFMT"\t%d\t"LLFMT"\t"LLFMT"\t%s\t%s\n",
+ x = sscanf(line,
"%d\t"LLFMT"\t"LLFMT"\t"LLFMT"\t"LLFMT"\t"LLFMT"\t%d\t"LLFMT"\t"LLFMT"\t%s\t%s\n",
&box[i].thread, &box[i].clkstart, &box[i].clkend,
&box[i].ticks, &box[i].memstart, &box[i].memend,
&box[i].state, &box[i].reads, &box[i].writes, buf,
buf2);
+ if (x != 11) {
+ fprintf(stderr, "scandata: sscanf() matched %d instead
of 11 items in\n'%s'\n", x, line);
+ }
+ if (box[i].thread < 0 || box[i].clkstart < 0 || box[i].clkend <
0 || box[i].ticks < 0 || box[i].memstart < 0 || box[i].memend < 0 ||
box[i].state < 0 || box[i].reads < 0 || box[i].writes < 0) {
+ fprintf(stderr, "scandata: sscanf() read negative
value(s) from\n'%s'\n", line);
+ }
box[i].fcn = strdup(buf);
box[i].stmt = strdup(buf);
/* focus on part of the time frame */
@@ -1550,6 +1557,7 @@ static void update(int state, int thread
/* ignore all instructions up to the first function call */
if (state >= PING || fcn == 0 || strncmp(fcn, "function", 8) !=
0)
return;
+ assert(clkticks >= 0);
starttime = clkticks;
return;
}
@@ -1568,8 +1576,19 @@ static void update(int state, int thread
return;
}
- assert(clkticks - starttime >= 0);
+ assert(clkticks >= 0);
clkticks -= starttime;
+ if (clkticks < 0) {
+ /* HACK: *TRY TO* compensate for the fact that the MAL
+ * profiler chops-off day information, and assume that
+ * clkticks is < starttime because the tomograph run
+ * crossed a day boundary (midnight);
+ * we simply add 1 day (24 hours) worth of microseconds.
+ * NOTE: this surely does NOT work correctly if the
+ * tomograph run takes 24 hours or more ...
+ */
+ clkticks += US_DD;
+ }
/* handle a ping event, keep the current instruction in focus */
if (state >= PING) {
@@ -1696,6 +1715,9 @@ static int parser(char *row)
clkticks += usec;
}
c = strchr(c + 1, (int) '"');
+ if (clkticks < 0) {
+ fprintf(stderr, "parser: read negative value "LLFMT"
from\n'%s'\n", clkticks, row);
+ }
} else
return -3;
diff --git a/gdk/gdk_heap.c b/gdk/gdk_heap.c
--- a/gdk/gdk_heap.c
+++ b/gdk/gdk_heap.c
@@ -111,8 +111,8 @@ HEAPcacheAdd(void *base, size_t maxsz, c
int added = 0;
+ MT_lock_set(&HEAPcacheLock, "HEAPcache_init");
if (hc && free_file && fn && storage == STORE_MMAP && hc->used <
hc->sz) {
- MT_lock_set(&HEAPcacheLock, "HEAPcache_init");
if (hc->used < hc->sz) {
heap_cache_e *e = hc->hc+hc->used;
@@ -124,8 +124,8 @@ HEAPcacheAdd(void *base, size_t maxsz, c
hc->used++;
added = 1;
}
- MT_lock_unset(&HEAPcacheLock, "HEAPcache_init");
}
+ MT_lock_unset(&HEAPcacheLock, "HEAPcache_init");
if (!added)
return GDKmunmap(base, maxsz);
HEAPDEBUG fprintf(stderr, "#HEAPcacheAdd (%s) " SZFMT " " PTRFMT " %d
%d %d\n", fn, maxsz, PTRFMTCAST base, (int) storage, free_file, hc->used);
@@ -138,79 +138,98 @@ HEAPcacheFind(size_t *maxsz, char *fn, s
void *base = NULL;
*maxsz = (1 + (*maxsz >> 16)) << 16; /* round up to 64K */
+ MT_lock_set(&HEAPcacheLock, "HEAPcache_init");
if (hc && mode == STORE_MMAP && hc->used < hc->sz) {
HEAPDEBUG fprintf(stderr, "#HEAPcacheFind (%s)" SZFMT " %d
%d\n", fn, *maxsz, (int) mode, hc->used);
- MT_lock_set(&HEAPcacheLock, "HEAPcache_init");
if (hc->used) {
int i;
heap_cache_e *e = NULL;
+ size_t cursz = 0;
- /* find best match */
- for(i=0;i<hc->used;i++) {
- if (hc->hc[i].maxsz >= *maxsz) {
- if (!e || hc->hc[i].maxsz < e->maxsz)
- e = hc->hc+i;
+ /* find best match: prefer smallest larger
+ * than or equal to requested, otherwise
+ * largest smaller than requested */
+ for (i = 0; i < hc->used; i++) {
+ if ((hc->hc[i].maxsz >= *maxsz &&
+ (e == NULL || hc->hc[i].maxsz < cursz)) ||
+ (hc->hc[i].maxsz < *maxsz &&
+ cursz < *maxsz &&
+ hc->hc[i].maxsz > cursz)) {
+ e = hc->hc + i;
+ cursz = e->maxsz;
}
}
- if (!e)
- e = hc->hc;
- i = (int) (e - hc->hc);
- if (e->maxsz < *maxsz) {
- /* resize file ? */
- FILE *fp;
- long_str fn;
+ if (e != NULL) {
+ if (e->maxsz < *maxsz) {
+ /* resize file ? */
+ FILE *fp;
+ long_str fn;
- GDKfilepath(fn, HCDIR, e->fn, NULL);
+ GDKfilepath(fn, HCDIR, e->fn, NULL);
- if ((fp = fopen(fn, "rb+")) != NULL &&
+ if ((fp = fopen(fn, "rb+")) != NULL &&
#ifdef _WIN64
- _fseeki64(fp, (ssize_t) *maxsz-1, SEEK_SET)
>= 0 &&
+ _fseeki64(fp, (ssize_t) *maxsz-1,
SEEK_SET) >= 0 &&
#else
#ifdef HAVE_FSEEKO
- fseeko(fp, (off_t) *maxsz-1, SEEK_SET) >= 0
&&
+ fseeko(fp, (off_t) *maxsz-1,
SEEK_SET) >= 0 &&
#else
- fseek(fp, (long) *maxsz-1, SEEK_SET) >= 0 &&
+ fseek(fp, (long) *maxsz-1,
SEEK_SET) >= 0 &&
#endif
#endif
- fputc('\n', fp) >= 0 &&
- fflush(fp) >= 0) {
- if (fclose(fp) >= 0) {
- void *base = GDKload(fn, NULL,
*maxsz, *maxsz, STORE_MMAP);
- GDKmunmap(e->base, e->maxsz);
- e->base = base;
- e->maxsz = *maxsz;
+ fputc('\n', fp) >= 0 &&
+ fflush(fp) >= 0) {
+ if (fclose(fp) >= 0) {
+ void *base =
GDKload(fn, NULL, *maxsz, *maxsz, STORE_MMAP);
+ GDKmunmap(e->base,
e->maxsz);
+ e->base = base;
+ e->maxsz = *maxsz;
+ } else {
+ /* extending
+ * may have
+ * failed
+ * since
+ * fclose
+ * failed */
+ e = NULL;
+ }
+ /* after fclose, successful or
+ * not, we can't call fclose
+ * again */
+ fp = NULL;
}
- /* after fclose, successful or
- * not, we can't call fclose
- * again */
- fp = NULL;
- }
- if (fp) {
- /* if set, extending the file failed */
- fclose(fp);
+ if (fp) {
+ /* if set, extending
+ * the file failed */
+ fclose(fp);
+ e = NULL;
+ }
}
}
- base = e->base;
- *maxsz = e->maxsz;
- if (GDKmove(HCDIR, e->fn, NULL, BATDIR, fn, NULL)<0) {
- /* try to create the directory, if
- * that was the problem */
- char path[PATHLENGTH];
+ if (e != NULL) {
+ base = e->base;
+ *maxsz = e->maxsz;
+ if (GDKmove(HCDIR, e->fn, NULL, BATDIR, fn,
NULL)<0) {
+ /* try to create the directory, if
+ * that was the problem */
+ char path[PATHLENGTH];
- GDKfilepath(path, BATDIR, fn, NULL);
- GDKcreatedir(path);
- GDKmove(HCDIR, e->fn, NULL, BATDIR, fn, NULL);
- }
- hc->used--;
- if (i < hc->used) {
- e->base = hc->hc[hc->used].base;
- e->maxsz = hc->hc[hc->used].maxsz;
- GDKmove(HCDIR, hc->hc[hc->used].fn, NULL,
HCDIR, e->fn, NULL);
+ GDKfilepath(path, BATDIR, fn, NULL);
+ GDKcreatedir(path);
+ GDKmove(HCDIR, e->fn, NULL, BATDIR, fn,
NULL);
+ }
+ hc->used--;
+ i = (int) (e - hc->hc);
+ if (i < hc->used) {
+ e->base = hc->hc[hc->used].base;
+ e->maxsz = hc->hc[hc->used].maxsz;
+ GDKmove(HCDIR, hc->hc[hc->used].fn,
NULL, HCDIR, e->fn, NULL);
+ }
}
}
- MT_lock_unset(&HEAPcacheLock, "HEAPcache_init");
}
+ MT_lock_unset(&HEAPcacheLock, "HEAPcache_init");
if (!base) {
int fd = GDKfdlocate(fn, "wb", NULL);
diff --git a/gdk/gdk_utils.c b/gdk/gdk_utils.c
--- a/gdk/gdk_utils.c
+++ b/gdk/gdk_utils.c
@@ -329,6 +329,7 @@ volatile ATOMIC_TYPE GDK_nmallocs[MAX_BI
#ifdef ATOMIC_LOCK
static MT_Lock mbyteslock;
static MT_Lock GDKstoppedLock;
+static MT_Lock vmtrimLock;
#endif
size_t _MT_pagesize = 0; /* variable holding memory size */
@@ -932,7 +933,10 @@ GDKmunmap(void *addr, size_t size)
#define CATNAP 500
int GDKrecovery = 0;
+#define VMTRIM_IDLE 0
+#define VMTRIM_BUSY 1
static MT_Id GDKvmtrim_id;
+static int vmtrimStatus = VMTRIM_BUSY; /* owned by vmtrim thread */
static void
GDKvmtrim(void *limit)
@@ -942,6 +946,7 @@ GDKvmtrim(void *limit)
(void) limit;
+ ATOMIC_INIT(vmtrim_lock, "GDKvmtrim")
do {
int t;
size_t rss;
@@ -950,9 +955,11 @@ GDKvmtrim(void *limit)
/* sleep using catnaps so we can exit in a timely fashion */
for (t = highload ? CATNAP : 10 * CATNAP; t > 0; t -= CATNAP) {
+ /* allow GDKexit to kill GDKvmtrim thread while
sleeping */
+ (void) ATOMIC_COMP_SWAP(vmtrimStatus, VMTRIM_BUSY,
VMTRIM_IDLE,vmtrimLock, "GDKvmtrim");
MT_sleep_ms(CATNAP);
_______________________________________________
checkin-list mailing list
[email protected]
http://mail.monetdb.org/mailman/listinfo/checkin-list