Changeset: 7f4136351704 for MonetDB URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=7f4136351704 Modified Files: gdk/gdk_heap.c Branch: default Log Message:
Send all HEAPDEBUG output to the server's stderr. Also print debug information for HEAPmargin. diffs (147 lines): diff --git a/gdk/gdk_heap.c b/gdk/gdk_heap.c --- a/gdk/gdk_heap.c +++ b/gdk/gdk_heap.c @@ -126,7 +126,7 @@ HEAPcacheAdd( void *base, size_t maxsz, } if (!added) return GDKmunmap(base, maxsz); - HEAPDEBUG mnstr_printf(GDKerr, "#HEAPcacheAdd (%s) " SZFMT " " PTRFMT " %d %d %d\n", fn, maxsz, PTRFMTCAST base, storage, free_file, hc->used); + HEAPDEBUG fprintf(stderr, "#HEAPcacheAdd (%s) " SZFMT " " PTRFMT " %d %d %d\n", fn, maxsz, PTRFMTCAST base, storage, free_file, hc->used); return 0; } @@ -137,7 +137,7 @@ HEAPcacheFind( size_t *maxsz, char *fn, *maxsz = (1 + (*maxsz >> 16)) << 16; /* round up to 64K */ if (hc && mode == STORE_MMAP && hc->used < hc->sz) { - HEAPDEBUG mnstr_printf(GDKerr, "#HEAPcacheFind (%s)" SZFMT " %d %d\n", fn, *maxsz, mode, hc->used); + HEAPDEBUG fprintf(stderr, "#HEAPcacheFind (%s)" SZFMT " %d %d\n", fn, *maxsz, mode, hc->used); gdk_set_lock(HEAPcacheLock, "HEAPcache_init"); if (hc->used) { @@ -207,7 +207,7 @@ HEAPcacheFind( size_t *maxsz, char *fn, return GDKload(fn, NULL, *maxsz, *maxsz, mode); } } else - HEAPDEBUG mnstr_printf(GDKerr, "#HEAPcacheFind (%s) re-used\n", fn); + HEAPDEBUG fprintf(stderr, "#HEAPcacheFind (%s) re-used\n", fn); return base; } @@ -246,6 +246,8 @@ HEAPmargin(size_t maxsize) if ((ret + ret) > (GDK_vm_maxsize - MIN(GDK_vm_maxsize, use))) /* only if room */ #endif ret = ((size_t) (((double) BATMARGIN) * (double) maxsize)) - 1; /* do not waste VM on 32-bits */ + HEAPDEBUG fprintf(stderr, "#HEAPmargin " SZFMT " -> " SZFMT "\n", + maxsize, (1 + (MAX(maxsize, ret) >> 16)) << 16); return (1 + (MAX(maxsize, ret) >> 16)) << 16; /* round up to 64K */ } @@ -283,7 +285,7 @@ HEAPalloc(Heap *h, size_t nitems, size_t if (h->filename == NULL || (h->size < minsize)) { h->storage = STORE_MEM; h->base = (char *) GDKmallocmax(h->size, &h->maxsize, 0); - HEAPDEBUG mnstr_printf(GDKerr, "#HEAPalloc " SZFMT " " SZFMT " " PTRFMT "%s\n", h->size, h->maxsize, PTRFMTCAST h->base, h->base && ((ssize_t*) h->base)[-1] < 0 ? " VM" : ""); + HEAPDEBUG fprintf(stderr, "#HEAPalloc " SZFMT " " SZFMT " " PTRFMT "%s\n", h->size, h->maxsize, PTRFMTCAST h->base, h->base && ((ssize_t*) h->base)[-1] < 0 ? " VM" : ""); } if (h->filename && h->base == NULL) { char *of = h->filename; @@ -345,7 +347,7 @@ HEAPextend(Heap *h, size_t size) return 0; if (h->storage != STORE_MEM) { - HEAPDEBUG mnstr_printf(GDKerr, "#HEAPextend: extending %s mmapped heap\n", h->storage == STORE_MMAP ? "shared" : "privately"); + HEAPDEBUG fprintf(stderr, "#HEAPextend: extending %s mmapped heap\n", h->storage == STORE_MMAP ? "shared" : "privately"); /* memory mapped files extend: save and remap */ if (HEAPsave_intern(h, nme, ext, ".tmp") < 0) return -1; @@ -379,7 +381,7 @@ HEAPextend(Heap *h, size_t size) void *p = h->base; h->newstorage = h->storage = STORE_MEM; h->base = (char *) GDKreallocmax(h->base, size, &h->maxsize, 0); - HEAPDEBUG mnstr_printf(GDKerr, "#HEAPextend: extending malloced heap " SZFMT " " SZFMT " " PTRFMT " " PTRFMT "\n", size, h->maxsize, PTRFMTCAST p, PTRFMTCAST h->base); + HEAPDEBUG fprintf(stderr, "#HEAPextend: extending malloced heap " SZFMT " " SZFMT " " PTRFMT " " PTRFMT "\n", size, h->maxsize, PTRFMTCAST p, PTRFMTCAST h->base); if (h->base) return 0; } @@ -412,7 +414,7 @@ HEAPextend(Heap *h, size_t size) h->forcemap = 0; } h->base = NULL; - HEAPDEBUG mnstr_printf(GDKerr, "#HEAPextend: converting malloced to %s mmapped heap\n", h->newstorage == STORE_MMAP ? "shared" : "privately"); + HEAPDEBUG fprintf(stderr, "#HEAPextend: converting malloced to %s mmapped heap\n", h->newstorage == STORE_MMAP ? "shared" : "privately"); /* try to allocate a memory-mapped based heap */ if (HEAPload(h, nme, ext, FALSE) >= 0) { /* copy data to heap and free old memory */ @@ -557,7 +559,7 @@ HEAPfree_(Heap *h, int free_file) { if (h->base) { if (h->storage == STORE_MEM) { /* plain memory */ - HEAPDEBUG mnstr_printf(GDKerr, "#HEAPfree " SZFMT " " SZFMT " " PTRFMT "%s\n", h->size, h->maxsize, PTRFMTCAST h->base, h->base && ((ssize_t*) h->base)[-1] < 0 ? " VM" : ""); + HEAPDEBUG fprintf(stderr, "#HEAPfree " SZFMT " " SZFMT " " PTRFMT "%s\n", h->size, h->maxsize, PTRFMTCAST h->base, h->base && ((ssize_t*) h->base)[-1] < 0 ? " VM" : ""); GDKfree(h->base); } else { /* mapped file, or STORE_PRIV */ int ret = HEAPcacheAdd(h->base, h->maxsize, h->filename, h->storage, free_file); @@ -566,7 +568,7 @@ HEAPfree_(Heap *h, int free_file) GDKsyserror("HEAPfree: %s was not mapped\n", h->filename); assert(0); } - HEAPDEBUG mnstr_printf(GDKerr, + HEAPDEBUG fprintf(stderr, "#munmap(base=" PTRFMT ", size=" SZFMT ") = %d\n", PTRFMTCAST(void *)h->base, h->maxsize, ret); @@ -626,7 +628,7 @@ HEAPload_intern(Heap *h, const char *nme fp = (FILE *) GDKfilelocate(nme, "mrb+", ext); if (fp) { ret = ftruncate(fileno(fp), (off_t) truncsize); - HEAPDEBUG mnstr_printf(GDKerr, "#ftruncate(file=%s.%s, size=" SZFMT ") = %d\n", nme, ext, truncsize, ret); + HEAPDEBUG fprintf(stderr, "#ftruncate(file=%s.%s, size=" SZFMT ") = %d\n", nme, ext, truncsize, ret); fclose(fp); if (ret == 0) { h->size = h->maxsize = truncsize; @@ -636,7 +638,7 @@ HEAPload_intern(Heap *h, const char *nme } HEAPDEBUG { - mnstr_printf(GDKerr, "#HEAPload(%s.%s,storage=%d,free=" SZFMT ",size=" SZFMT ")\n", nme, ext, h->storage, h->free, h->size); + fprintf(stderr, "#HEAPload(%s.%s,storage=%d,free=" SZFMT ",size=" SZFMT ")\n", nme, ext, h->storage, h->free, h->size); } /* On some OSs (WIN32,Solaris), it is prohibited to write to a file that is open in MAP_PRIVATE (FILE_MAP_COPY) @@ -653,7 +655,7 @@ HEAPload_intern(Heap *h, const char *nme if (ret == 0) { t0 = GDKms(); ret = unlink(dstpath); - HEAPDEBUG mnstr_printf(GDKerr, "#unlink %s = %d (%dms)\n", dstpath, ret, GDKms() - t0); + HEAPDEBUG fprintf(stderr, "#unlink %s = %d (%dms)\n", dstpath, ret, GDKms() - t0); } t0 = GDKms(); ret = rename(srcpath, dstpath); @@ -661,7 +663,7 @@ HEAPload_intern(Heap *h, const char *nme GDKsyserror("HEAPload: rename of %s failed\n", srcpath); return -1; } - HEAPDEBUG mnstr_printf(GDKerr, "#rename %s %s = %d (%dms)\n", srcpath, dstpath, ret, GDKms() - t0); + HEAPDEBUG fprintf(stderr, "#rename %s %s = %d (%dms)\n", srcpath, dstpath, ret, GDKms() - t0); } h->base = (char *) GDKload(nme, ext, h->free, h->size, h->newstorage); @@ -708,7 +710,7 @@ HEAPsave_intern(Heap *h, const char *nme store = h->storage; } HEAPDEBUG { - mnstr_printf(GDKerr, "#HEAPsave(%s.%s,storage=%d,free=" SZFMT ",size=" SZFMT ")\n", nme, ext, h->newstorage, h->free, h->size); + fprintf(stderr, "#HEAPsave(%s.%s,storage=%d,free=" SZFMT ",size=" SZFMT ")\n", nme, ext, h->newstorage, h->free, h->size); } return GDKsave(nme, ext, h->base, h->free, store); } @@ -1017,7 +1019,7 @@ HEAP_malloc(Heap *heap, size_t nbytes) // Double the size of the heap. // TUNE: increase heap by diffent amount. */ - HEAPDEBUG mnstr_printf(GDKerr, "#HEAPextend in HEAP_malloc %s " SZFMT " " SZFMT "\n", heap->filename, heap->size, newsize); + HEAPDEBUG fprintf(stderr, "#HEAPextend in HEAP_malloc %s " SZFMT " " SZFMT "\n", heap->filename, heap->size, newsize); if (HEAPextend(heap, newsize) < 0) return 0; heap->free = newsize; _______________________________________________ Checkin-list mailing list Checkin-list@monetdb.org http://mail.monetdb.org/mailman/listinfo/checkin-list