Changeset: 30f0f131f6bc for MonetDB URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=30f0f131f6bc Modified Files: gdk/gdk_bat.c gdk/gdk_heap.c gdk/gdk_storage.c gdk/gdk_tracer.h Branch: gdk_tracer Log Message:
Added GDKtracer to gdk_bat, gdk_heap, gdk_storage diffs (truncated from 631 to 300 lines): diff --git a/gdk/gdk_bat.c b/gdk/gdk_bat.c --- a/gdk/gdk_bat.c +++ b/gdk/gdk_bat.c @@ -212,7 +212,7 @@ COLnew(oid hseq, int tt, BUN cap, role_t GDKfree(bn->tvheap); goto bailout; } - ALGODEBUG fprintf(stderr, "#COLnew()=" ALGOBATFMT "\n", ALGOBATPAR(bn)); + DEBUG(ALGO, "COLnew()=" ALGOBATFMT "\n", ALGOBATPAR(bn)); return bn; bailout: BBPclear(bn->batCacheid); @@ -231,7 +231,7 @@ BATdense(oid hseq, oid tseq, BUN cnt) if (bn != NULL) { BATtseqbase(bn, tseq); BATsetcount(bn, cnt); - ALGODEBUG fprintf(stderr, "#BATdense()=" ALGOBATFMT "\n", ALGOBATPAR(bn)); + DEBUG(ALGO, "BATdense()=" ALGOBATFMT "\n", ALGOBATPAR(bn)); } return bn; } @@ -449,7 +449,7 @@ BATextend(BAT *b, BUN newcap) theap_size *= Tsize(b); if (b->theap.base && GDKdebug & HEAPMASK) - fprintf(stderr, "#HEAPextend in BATextend %s %zu %zu\n", b->theap.filename, b->theap.size, theap_size); + INFO(BAT_, "HEAPextend in BATextend %s %zu %zu\n", b->theap.filename, b->theap.size, theap_size); if (b->theap.base && HEAPextend(&b->theap, theap_size, b->batRestricted == BAT_READ) != GDK_SUCCEED) return GDK_FAIL; @@ -848,8 +848,8 @@ COLcopy(BAT *b, int tt, bool writable, r } if (!writable) bn->batRestricted = BAT_READ; - ALGODEBUG fprintf(stderr, "#COLcopy(" ALGOBATFMT ")=" ALGOBATFMT "\n", - ALGOBATPAR(b), ALGOBATPAR(bn)); + DEBUG(ALGO, "COLcopy(" ALGOBATFMT ")=" ALGOBATFMT "\n", + ALGOBATPAR(b), ALGOBATPAR(bn)); return bn; bunins_failed: BBPreclaim(bn); @@ -1854,12 +1854,12 @@ backup_new(Heap *hp, int lockbat) if ((ret = rename(batpath, bakpath)) < 0) GDKsyserror("backup_new: rename %s to %s failed\n", batpath, bakpath); - IODEBUG fprintf(stderr, "#rename(%s,%s) = %d\n", batpath, bakpath, ret); + DEBUG(IO_, "rename(%s,%s) = %d\n", batpath, bakpath, ret); } else if (batret == 0) { /* there is a backup already; just remove the X.new */ if ((ret = remove(batpath)) != 0) GDKsyserror("backup_new: remove %s failed\n", batpath); - IODEBUG fprintf(stderr, "#remove(%s) = %d\n", batpath, ret); + DEBUG(IO_, "remove(%s) = %d\n", batpath, ret); } GDKfree(batpath); GDKfree(bakpath); @@ -1967,7 +1967,7 @@ BATsetaccess(BAT *b, restrict_t newmode) storage_t b1, b3 = STORE_MEM; if (b->batSharecnt && newmode != BAT_READ) { - BATDEBUG fprintf(stderr, "#BATsetaccess: %s has %d views; try creating a copy\n", BATgetId(b), b->batSharecnt); + DEBUG(BAT_, "%s has %d views; try creating a copy\n", BATgetId(b), b->batSharecnt); GDKerror("BATsetaccess: %s has %d views\n", BATgetId(b), b->batSharecnt); return GDK_FAIL; @@ -2114,7 +2114,7 @@ BATmode(BAT *b, bool transient) #ifdef NDEBUG /* assertions are disabled, turn failing tests into a message */ #undef assert -#define assert(test) ((void) ((test) || fprintf(stderr, "!WARNING: %s:%d: assertion `%s' failed\n", __FILE__, __LINE__, #test))) +#define assert(test) ((void) ((test) || WARNING(BAT_, "Assertion `%s' failed\n", #test))) #endif /* Assert that properties are set correctly. @@ -2387,17 +2387,13 @@ BATassertProps(BAT *b) int len; if ((hs = GDKzalloc(sizeof(Hash))) == NULL) { - fprintf(stderr, - "#BATassertProps: cannot allocate " - "hash table\n"); + ERROR(BAT_, "Cannot allocate hash table\n"); goto abort_check; } len = snprintf(hs->heap.filename, sizeof(hs->heap.filename), "%s.hash%d", nme, THRgettid()); if (len == -1 || len > (int) sizeof(hs->heap.filename)) { GDKfree(hs); - fprintf(stderr, - "#BATassertProps: heap filename " - "is too large\n"); + ERROR(BAT_, "Heap filename is too large\n"); goto abort_check; } if (ATOMsize(b->ttype) == 1) @@ -2411,9 +2407,7 @@ BATassertProps(BAT *b) HASHnew(hs, b->ttype, BUNlast(b), mask, BUN_NONE) != GDK_SUCCEED) { GDKfree(hs); - fprintf(stderr, - "#BATassertProps: cannot allocate " - "hash table\n"); + ERROR(BAT_, "Cannot allocate hash table\n"); goto abort_check; } BATloop(b, p, q) { diff --git a/gdk/gdk_heap.c b/gdk/gdk_heap.c --- a/gdk/gdk_heap.c +++ b/gdk/gdk_heap.c @@ -114,7 +114,7 @@ HEAPalloc(Heap *h, size_t nitems, size_t h->size < (h->farmid == 0 ? GDK_mmap_minsize_persistent : GDK_mmap_minsize_transient))) { h->storage = STORE_MEM; h->base = GDKmalloc(h->size); - HEAPDEBUG fprintf(stderr, "#HEAPalloc %zu %p\n", h->size, h->base); + DEBUG(HEAP, "HEAPalloc %zu %p\n", h->size, h->base); } if (!GDKinmemory() && h->base == NULL) { char *nme; @@ -174,7 +174,7 @@ HEAPextend(Heap *h, size_t size, bool ma char *p; char *path; - HEAPDEBUG fprintf(stderr, "#HEAPextend: extending %s mmapped heap (%s)\n", h->storage == STORE_MMAP ? "shared" : "privately", h->filename); + DEBUG(HEAP, "Extending %s mmapped heap (%s)\n", h->storage == STORE_MMAP ? "shared" : "privately", h->filename); /* extend memory mapped file */ if ((path = GDKfilepath(h->farmid, BATDIR, nme, ext)) == NULL) { return GDK_FAIL; @@ -209,7 +209,7 @@ HEAPextend(Heap *h, size_t size, bool ma if (!must_mmap) { h->newstorage = h->storage = STORE_MEM; h->base = GDKrealloc(h->base, size); - HEAPDEBUG fprintf(stderr, "#HEAPextend: extending malloced heap %zu %zu %p %p\n", size, h->size, bak.base, h->base); + DEBUG(HEAP, "Extending malloced heap %zu %zu %p %p\n", size, h->size, bak.base, h->base); h->size = size; if (h->base) return GDK_SUCCEED; /* success */ @@ -253,7 +253,7 @@ HEAPextend(Heap *h, size_t size, bool ma h->newstorage = h->storage; h->base = NULL; - HEAPDEBUG fprintf(stderr, "#HEAPextend: converting malloced to %s mmapped heap\n", h->newstorage == STORE_MMAP ? "shared" : "privately"); + DEBUG(HEAP, "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) == GDK_SUCCEED) { @@ -302,10 +302,10 @@ HEAPshrink(Heap *h, size_t size) assert(size <= h->size); if (h->storage == STORE_MEM) { p = GDKrealloc(h->base, size); - HEAPDEBUG fprintf(stderr, "#HEAPshrink: shrinking malloced " - "heap %zu %zu %p " - "%p\n", h->size, size, - h->base, p); + DEBUG(HEAP, "Shrinking malloced " + "heap %zu %zu %p " + "%p\n", h->size, size, + h->base, p); } else { char *path; @@ -327,12 +327,12 @@ HEAPshrink(Heap *h, size_t size) MMAP_READ | MMAP_WRITE, h->base, h->size, &size); GDKfree(path); - HEAPDEBUG fprintf(stderr, "#HEAPshrink: shrinking %s mmapped " - "heap (%s) %zu %zu %p " - "%p\n", - h->storage == STORE_MMAP ? "shared" : "privately", - h->filename, h->size, size, - h->base, p); + DEBUG(HEAP, "Shrinking %s mmapped " + "heap (%s) %zu %zu %p " + "%p\n", + h->storage == STORE_MMAP ? "shared" : "privately", + h->filename, h->size, size, + h->base, p); } if (p) { h->size = size; @@ -352,7 +352,7 @@ file_exists(int farmid, const char *dir, path = GDKfilepath(farmid, dir, name, ext); ret = stat(path, &st); - IODEBUG fprintf(stderr, "#stat(%s) = %d\n", path, ret); + DEBUG(IO_, "stat(%s) = %d\n", path, ret); GDKfree(path); return (ret == 0); } @@ -549,9 +549,9 @@ HEAPfree(Heap *h, bool rmheap) { if (h->base) { if (h->storage == STORE_MEM) { /* plain memory */ - HEAPDEBUG fprintf(stderr, "#HEAPfree %zu" - " %p\n", - h->size, h->base); + DEBUG(HEAP, "HEAPfree %zu" + " %p\n", + h->size, h->base); GDKfree(h->base); } else if (h->storage == STORE_CMEM) { //heap is stored in regular C memory rather than GDK memory,so we call free() @@ -564,10 +564,10 @@ HEAPfree(Heap *h, bool rmheap) h->filename); assert(0); } - HEAPDEBUG fprintf(stderr, "#munmap(base=%p, " - "size=%zu) = %d\n", - (void *)h->base, - h->size, (int) ret); + DEBUG(HEAP, "munmap(base=%p, " + "size=%zu) = %d\n", + (void *)h->base, + h->size, (int) ret); } } h->base = NULL; @@ -624,9 +624,8 @@ HEAPload_intern(Heap *h, const char *nme if (truncsize < h->size && (fd = GDKfdlocate(h->farmid, nme, "mrb+", ext)) >= 0) { ret = ftruncate(fd, truncsize); - HEAPDEBUG fprintf(stderr, - "#ftruncate(file=%s.%s, size=%zu" - ") = %d\n", nme, ext, truncsize, ret); + DEBUG(HEAP, "#ftruncate(file=%s.%s, size=%zu" + ") = %d\n", nme, ext, truncsize, ret); close(fd); if (ret == 0) { h->size = truncsize; @@ -634,9 +633,9 @@ HEAPload_intern(Heap *h, const char *nme } } - HEAPDEBUG fprintf(stderr, "#HEAPload(%s.%s,storage=%d,free=%zu" - ",size=%zu)\n", nme, ext, - (int) h->storage, h->free, h->size); + DEBUG(HEAP, "HEAPload(%s.%s,storage=%d,free=%zu" + ",size=%zu)\n", nme, ext, + (int) 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) solution: @@ -656,9 +655,9 @@ HEAPload_intern(Heap *h, const char *nme t0 = GDKms(); ret = rename(srcpath, dstpath); - HEAPDEBUG fprintf(stderr, "#rename %s %s = %d %s (%dms)\n", - srcpath, dstpath, ret, ret < 0 ? strerror(errno) : "", - GDKms() - t0); + DEBUG(HEAP, "rename %s %s = %d %s (%dms)\n", + srcpath, dstpath, ret, ret < 0 ? strerror(errno) : "", + GDKms() - t0); GDKfree(srcpath); GDKfree(dstpath); @@ -709,9 +708,8 @@ HEAPsave_intern(Heap *h, const char *nme } else if (store != STORE_MEM) { store = h->storage; } - HEAPDEBUG { - fprintf(stderr, "#HEAPsave(%s.%s,storage=%d,free=%zu,size=%zu)\n", nme, ext, (int) h->newstorage, h->free, h->size); - } + DEBUG(HEAP, "HEAPsave(%s.%s,storage=%d,free=%zu,size=%zu)\n", nme, ext, (int) h->newstorage, h->free, h->size); + return GDKsave(h->farmid, nme, ext, h->base, h->free, store, true); } @@ -804,8 +802,6 @@ HEAPmemsize(Heap *h) * TODO: user HEADER64 for both 32 and 64 bits (requires BAT format * change) */ -/* #define DEBUG */ -/* #define TRACE */ #define HEAPVERSION 20030408 @@ -853,7 +849,7 @@ roundup_num(size_t number, int alignment #define HEAP_index(HEAP,INDEX,TYPE) ((TYPE *)((char *) (HEAP)->base + (INDEX))) -#ifdef TRACE + static void HEAP_printstatus(Heap *heap) { @@ -861,9 +857,8 @@ HEAP_printstatus(Heap *heap) size_t block, cur_free = hheader->head; CHUNK *blockp; - fprintf(stderr, - "#HEAP has head %zu and alignment %d and size %zu\n", - hheader->head, hheader->alignment, heap->free); + DEBUG(TRACE, "HEAP has head %zu and alignment %d and size %zu\n", + hheader->head, hheader->alignment, heap->free); /* Walk the blocklist */ block = hheader->firstblock; @@ -872,24 +867,21 @@ HEAP_printstatus(Heap *heap) blockp = HEAP_index(heap, block, CHUNK); if (block == cur_free) { - fprintf(stderr, _______________________________________________ checkin-list mailing list checkin-list@monetdb.org https://www.monetdb.org/mailman/listinfo/checkin-list