Changeset: b8907c9beb86 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/b8907c9beb86 Modified Files: clients/Tests/exports.stable.out gdk/gdk_bbp.c gdk/gdk_imprints.c gdk/gdk_private.h gdk/gdk_system.c gdk/gdk_utils.c gdk/gdk_utils.h tools/mserver/mserver5.c Branch: default Log Message:
Implemented initial version of printing info when a SIGUSR1 is received. Info is printed to stdout. diffs (truncated from 438 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 @@ -301,6 +301,7 @@ int GDKms(void); gdk_return GDKmunmap(void *addr, size_t len); int GDKnr_threads; void GDKprepareExit(void); +void GDKprintinfo(void); void GDKqsort(void *restrict h, void *restrict t, const void *restrict base, size_t n, int hs, int ts, int tpe, bool reverse, bool nilslast); void *GDKrealloc(void *pold, size_t size) __attribute__((__alloc_size__(2))) __attribute__((__warn_unused_result__)); gdk_return GDKrebuild_segment_tree(oid ncount, oid data_size, BAT *st, void **segment_tree, oid **levels_offset, oid *nlevels); diff --git a/gdk/gdk_bbp.c b/gdk/gdk_bbp.c --- a/gdk/gdk_bbp.c +++ b/gdk/gdk_bbp.c @@ -2227,31 +2227,27 @@ BBPdump(void) continue; BAT *b = BBP_desc(i); unsigned status = BBP_status(i); - fprintf(stderr, - "# %d: " ALGOOPTBATFMT " " - "refs=%d lrefs=%d " - "status=%u%s", - i, - ALGOOPTBATPAR(b), - BBP_refs(i), - BBP_lrefs(i), - status, - BBP_cache(i) ? "" : " not cached"); + printf("# %d: " ALGOOPTBATFMT "refs=%d lrefs=%d status=%u%s", + i, + ALGOOPTBATPAR(b), + BBP_refs(i), + BBP_lrefs(i), + status, + BBP_cache(i) ? "" : " not cached"); if (b == NULL) { - fprintf(stderr, ", no descriptor\n"); + printf(", no descriptor\n"); continue; } if (b->theap) { if (b->theap->parentid != b->batCacheid) { - fprintf(stderr, " Theap -> %d", b->theap->parentid); + printf(" Theap -> %d", b->theap->parentid); } else { - fprintf(stderr, - " Theap=[%zu,%zu,f=%d]%s%s", - b->theap->free, - b->theap->size, - b->theap->farmid, - b->theap->base == NULL ? "X" : b->theap->storage == STORE_MMAP ? "M" : "", - status & BBPSWAPPED ? "(Swapped)" : b->theap->dirty ? "(Dirty)" : ""); + printf(" Theap=[%zu,%zu,f=%d]%s%s", + b->theap->free, + b->theap->size, + b->theap->farmid, + b->theap->base == NULL ? "X" : b->theap->storage == STORE_MMAP ? "M" : "", + status & BBPSWAPPED ? "(Swapped)" : b->theap->dirty ? "(Dirty)" : ""); mem += HEAPmemsize(b->theap); vm += HEAPvmsize(b->theap); n++; @@ -2259,17 +2255,15 @@ BBPdump(void) } if (b->tvheap) { if (b->tvheap->parentid != b->batCacheid) { - fprintf(stderr, - " Tvheap -> %d", - b->tvheap->parentid); + printf(" Tvheap -> %d", + b->tvheap->parentid); } else { - fprintf(stderr, - " Tvheap=[%zu,%zu,f=%d]%s%s", - b->tvheap->free, - b->tvheap->size, - b->tvheap->farmid, - b->tvheap->base == NULL ? "X" : b->tvheap->storage == STORE_MMAP ? "M" : "", - b->tvheap->dirty ? "(Dirty)" : ""); + printf(" Tvheap=[%zu,%zu,f=%d]%s%s", + b->tvheap->free, + b->tvheap->size, + b->tvheap->farmid, + b->tvheap->base == NULL ? "X" : b->tvheap->storage == STORE_MMAP ? "M" : "", + b->tvheap->dirty ? "(Dirty)" : ""); mem += HEAPmemsize(b->tvheap); vm += HEAPvmsize(b->tvheap); } @@ -2278,19 +2272,19 @@ BBPdump(void) if (b->thash && b->thash != (Hash *) 1) { size_t m = HEAPmemsize(&b->thash->heaplink) + HEAPmemsize(&b->thash->heapbckt); size_t v = HEAPvmsize(&b->thash->heaplink) + HEAPvmsize(&b->thash->heapbckt); - fprintf(stderr, " Thash=[%zu,%zu,f=%d/%d]", m, v, - b->thash->heaplink.farmid, - b->thash->heapbckt.farmid); + printf(" Thash=[%zu,%zu,f=%d/%d]", m, v, + b->thash->heaplink.farmid, + b->thash->heapbckt.farmid); mem += m; vm += v; } MT_rwlock_rdunlock(&b->thashlock); } - fprintf(stderr, " role: %s\n", - b->batRole == PERSISTENT ? "persistent" : "transient"); + printf(" role: %s\n", + b->batRole == PERSISTENT ? "persistent" : "transient"); } - fprintf(stderr, "# %d bats: mem=%zu, vm=%zu\n", n, mem, vm); - fflush(stderr); + printf("# %d bats: mem=%zu, vm=%zu\n", n, mem, vm); + fflush(stdout); } /* @@ -4523,20 +4517,23 @@ BBPcallbacks(void) static MT_Lock GDKtmLock = MT_LOCK_INITIALIZER(GDKtmLock); static int lockfd; +static void +BBPtmlockFinish(void) +{ + if (!GDKinmemory(0) && + /* also use an external lock file to synchronize with + * external programs */ + (lockfile != NULL || + (lockfile = GDKfilepath(0, NULL, ".tm_lock", NULL)) != NULL)) { + lockfd = MT_lockf(lockfile, F_LOCK); + } +} + void BBPtmlock(void) { MT_lock_set(&GDKtmLock); - if (GDKinmemory(0)) - return; - /* also use an external lock file to synchronize with external - * programs */ - if (lockfile == NULL) { - lockfile = GDKfilepath(0, NULL, ".tm_lock", NULL); - if (lockfile == NULL) - return; - } - lockfd = MT_lockf(lockfile, F_LOCK); + BBPtmlockFinish(); } void @@ -4550,3 +4547,51 @@ BBPtmunlock(void) } MT_lock_unset(&GDKtmLock); } + +void +BBPprintinfo(void) +{ + if (MT_lock_try(&GDKtmLock)) { + BBPtmlockFinish(); + size_t tmem = 0, tvm = 0; + size_t pmem = 0, pvm = 0; + int tn = 0; + int pn = 0; + int nh = 0; + + for (bat i = 1, sz = (bat) ATOMIC_GET(&BBPsize); i < sz; i++) { + if (BBP_refs(i) == 0 && BBP_lrefs(i) == 0) + continue; + BAT *b = BBP_desc(i); + if (b == NULL) + continue; + ATOMIC_BASE_TYPE status = BBP_status(i); + nh += (status & BBPHOT) != 0; + if (status & BBPPERSISTENT) { + pn++; + pmem += HEAPmemsize(b->theap); + pvm += HEAPvmsize(b->theap); + pmem += HEAPmemsize(b->tvheap); + pvm += HEAPvmsize(b->tvheap); + } else { + tn++; + if (b->theap && + b->theap->parentid == b->batCacheid) { + tmem += HEAPmemsize(b->theap); + tvm += HEAPvmsize(b->theap); + } + if (b->tvheap && + b->tvheap->parentid == b->batCacheid) { + tmem += HEAPmemsize(b->tvheap); + tvm += HEAPvmsize(b->tvheap); + } + } + } + BBPtmunlock(); + printf("%d persistent bats using %zu virtual memory (%zu malloced)\n", pn, pvm, pmem); + printf("%d transient bats using %zu virtual memory (%zu malloced)\n", tn, tvm, tmem); + printf("%d bats are \"hot\" (i.e. currently or recently used)\n", nh); + } else { + printf("BBP currently locked, so no information available\n"); + } +} diff --git a/gdk/gdk_imprints.c b/gdk/gdk_imprints.c --- a/gdk/gdk_imprints.c +++ b/gdk/gdk_imprints.c @@ -871,7 +871,7 @@ IMPSprint(BAT *b) int i; if (!BATcheckimprints(b)) { - fprintf(stderr, "No imprint\n"); + printf("No imprint\n"); return; } imprints = b->timprints; @@ -880,35 +880,35 @@ IMPSprint(BAT *b) max_bins = min_bins + 64; cnt_bins = max_bins + 64; - fprintf(stderr, - "bits = %d, impcnt = " BUNFMT ", dictcnt = " BUNFMT "\n", - imprints->bits, imprints->impcnt, imprints->dictcnt); - fprintf(stderr, "MIN\n"); + printf("bits = %d, impcnt = " BUNFMT ", dictcnt = " BUNFMT "\n", + imprints->bits, imprints->impcnt, imprints->dictcnt); + printf("MIN\n"); for (i = 0; i < imprints->bits; i++) { - fprintf(stderr, "[ " BUNFMT " ]\n", min_bins[i]); + printf("[ " BUNFMT " ]\n", min_bins[i]); } - fprintf(stderr, "MAX\n"); + printf("MAX\n"); for (i = 0; i < imprints->bits; i++) { - fprintf(stderr, "[ " BUNFMT " ]\n", max_bins[i]); + printf("[ " BUNFMT " ]\n", max_bins[i]); } - fprintf(stderr, "COUNT\n"); + printf("COUNT\n"); for (i = 0; i < imprints->bits; i++) { - fprintf(stderr, "[ " BUNFMT " ]\n", cnt_bins[i]); + printf("[ " BUNFMT " ]\n", cnt_bins[i]); } for (dcnt = 0, icnt = 0, pages = 1; dcnt < imprints->dictcnt; dcnt++) { if (d[dcnt].repeat) { BINSIZE(imprints->bits, IMPSPRNTMASK, " "); pages += d[dcnt].cnt; - fprintf(stderr, "[ " BUNFMT " ]r %s\n", pages, s); + printf("[ " BUNFMT " ]r %s\n", pages, s); icnt++; } else { l = icnt + d[dcnt].cnt; for (; icnt < l; icnt++) { BINSIZE(imprints->bits, IMPSPRNTMASK, " "); - fprintf(stderr, "[ " BUNFMT " ] %s\n", pages++, s); + printf("[ " BUNFMT " ] %s\n", pages++, s); } } } + fflush(stdout); } #endif diff --git a/gdk/gdk_private.h b/gdk/gdk_private.h --- a/gdk/gdk_private.h +++ b/gdk/gdk_private.h @@ -110,6 +110,8 @@ gdk_return BBPinit(void) bat BBPinsert(BAT *bn) __attribute__((__warn_unused_result__)) __attribute__((__visibility__("hidden"))); +void BBPprintinfo(void) + __attribute__((__visibility__("hidden"))); void BBPrelinquish(Thread t) __attribute__((__visibility__("hidden"))); int BBPselectfarm(role_t role, int type, enum heaptype hptype) diff --git a/gdk/gdk_system.c b/gdk/gdk_system.c --- a/gdk/gdk_system.c +++ b/gdk/gdk_system.c @@ -140,7 +140,7 @@ GDKlockstatistics(int what) int n = 0; if (ATOMIC_TAS(&GDKlocklistlock) != 0) { - fprintf(stderr, "GDKlocklistlock is set, so cannot access lock list\n"); + printf("GDKlocklistlock is set, so cannot access lock list\n"); return; } if (what == -1) { @@ -153,27 +153,28 @@ GDKlockstatistics(int what) return; } GDKlocklist = sortlocklist(GDKlocklist); - fprintf(stderr, "%-18s\t%s\t%s\t%s\t%s\t%s\t%s\n", - "lock name", "count", "content", "sleep", - "locked", "locker", "thread"); + printf("%-18s\t%s\t%s\t%s\t%s\t%s\t%s\n", + "lock name", "count", "content", "sleep", + "locked", "locker", "thread"); for (l = GDKlocklist; l; l = l->next) { n++; if (what == 0 || (what == 1 && l->count) || (what == 2 && ATOMIC_GET(&l->contention)) || (what == 3 && lock_isset(l))) - fprintf(stderr, "%-18s\t%zu\t%zu\t%zu\t%s\t%s\t%s\n", _______________________________________________ checkin-list mailing list -- checkin-list@monetdb.org To unsubscribe send an email to checkin-list-le...@monetdb.org