Changeset: 50c0123fb80d for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/50c0123fb80d Branch: default Log Message:
Merge with Dec2023 branch. diffs (truncated from 585 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 @@ -3,7 +3,7 @@ int ALIGNsynced(BAT *b1, BAT *b2); int ATOMallocate(const char *nme); void *ATOMdup(int id, const void *val); uint8_t ATOMelmshift(int sz) __attribute__((__const__)); -char *ATOMformat(int id, const void *val); +char *ATOMformat(int id, const void *val) __attribute__((__warn_unused_result__)); gdk_return ATOMheap(int id, Heap *hp, size_t cap) __attribute__((__warn_unused_result__)); int ATOMindex(const char *nme); size_t ATOMlen(int id, const void *v); @@ -310,6 +310,7 @@ gdk_return GDKmunmap(void *addr, int mod int GDKnr_threads; void GDKprepareExit(void); void GDKprintinfo(void); +void GDKprintinforegister(void (*func)(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); @@ -423,7 +424,7 @@ int VALcmp(const ValRecord *p, const Val void *VALconvert(int typ, ValPtr t); ValPtr VALcopy(ValPtr dst, const ValRecord *src); void VALempty(ValPtr v); -char *VALformat(const ValRecord *res); +char *VALformat(const ValRecord *res) __attribute__((__warn_unused_result__)); void *VALget(ValPtr v); ValPtr VALinit(ValPtr d, int tpe, const void *s); bool VALisnil(const ValRecord *v); @@ -558,6 +559,7 @@ gdk_return log_delta(logger *lg, BAT *ui void log_destroy(logger *lg); log_bid log_find_bat(logger *lg, log_id id); gdk_return log_flush(logger *lg, ulng saved_id); +void log_printinfo(logger *lg); int log_sequence(logger *lg, int seq, lng *id); gdk_return log_tend(logger *lg); gdk_return log_tflush(logger *lg, ulng log_file_id, ulng commit_ts); @@ -872,8 +874,8 @@ char *concatErrors(char *err1, const cha const char *connectRef; const char *containsRef; str convertConstant(malType type, ValPtr vr); -InstrPtr copyInstruction(InstrPtr p); -InstrPtr copyInstructionArgs(InstrPtr p, int args); +InstrPtr copyInstruction(const InstrRecord *p); +InstrPtr copyInstructionArgs(const InstrRecord *p, int args); MalBlkPtr copyMalBlk(MalBlkPtr mb); const char *copy_fromRef; const char *corrRef; diff --git a/gdk/gdk.h b/gdk/gdk.h --- a/gdk/gdk.h +++ b/gdk/gdk.h @@ -656,7 +656,8 @@ typedef struct { /* interface definitions */ gdk_export void *VALconvert(int typ, ValPtr t); -gdk_export char *VALformat(const ValRecord *res); +gdk_export char *VALformat(const ValRecord *res) + __attribute__((__warn_unused_result__)); gdk_export ValPtr VALcopy(ValPtr dst, const ValRecord *src); gdk_export ValPtr VALinit(ValPtr d, int tpe, const void *s); gdk_export void VALempty(ValPtr v); diff --git a/gdk/gdk_atoms.h b/gdk/gdk_atoms.h --- a/gdk/gdk_atoms.h +++ b/gdk/gdk_atoms.h @@ -75,7 +75,8 @@ gdk_export size_t ATOMlen(int id, const gdk_export void *ATOMnil(int id) __attribute__((__malloc__)); gdk_export int ATOMprint(int id, const void *val, stream *fd); -gdk_export char *ATOMformat(int id, const void *val); +gdk_export char *ATOMformat(int id, const void *val) + __attribute__((__warn_unused_result__)); gdk_export void *ATOMdup(int id, const void *val); diff --git a/gdk/gdk_bbp.c b/gdk/gdk_bbp.c --- a/gdk/gdk_bbp.c +++ b/gdk/gdk_bbp.c @@ -4618,47 +4618,47 @@ BBPtmunlock(void) 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; + size_t tmem = 0, tvm = 0; + size_t pmem = 0, pvm = 0; + int tn = 0; + int pn = 0; + int nh = 0; + + BBPtmlock(); + for (bat i = 1, sz = (bat) ATOMIC_GET(&BBPsize); i < sz; i++) { + MT_lock_set(&GDKswapLock(i)); + if (BBP_refs(i) > 0 || BBP_lrefs(i) > 0) { 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 != NULL) { + ATOMIC_BASE_TYPE status = BBP_status(i); + nh += (status & BBPHOT) != 0; + MT_lock_set(&b->theaplock); + 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); + } } - if (b->tvheap && - b->tvheap->parentid == b->batCacheid) { - tmem += HEAPmemsize(b->tvheap); - tvm += HEAPvmsize(b->tvheap); - } + MT_lock_unset(&b->theaplock); } } - 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"); + MT_lock_unset(&GDKswapLock(i)); } + 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); } diff --git a/gdk/gdk_logger.c b/gdk/gdk_logger.c --- a/gdk/gdk_logger.c +++ b/gdk/gdk_logger.c @@ -2256,6 +2256,7 @@ log_new(int debug, const char *fn, const .saved_id = getBBPlogno(), /* get saved log numer from bbp */ .saved_tid = (int) getBBPtransid(), /* get saved transaction id from bbp */ }; + lg->tid = lg->saved_tid; /* probably open file and check version first, then call call old logger code */ if (snprintf(filename, sizeof(filename), "%s%c%s%c", logdir, DIR_SEP, fn, DIR_SEP) >= FILENAME_MAX) { @@ -3371,3 +3372,25 @@ log_tstart(logger *lg, bool flushnow, ul return GDK_SUCCEED; } + +void +log_printinfo(logger *lg) +{ + printf("logger %s:\n", lg->fn); + rotation_lock(lg); + printf("current log file "ULLFMT", last handled log file "ULLFMT"\n", + lg->id, lg->saved_id); + rotation_unlock(lg); + printf("current transaction id %d, saved transaction id %d\n", + lg->tid, lg->saved_tid); + printf("number of flushers: %d, number of open files %d\n", + (int) ATOMIC_GET(&lg->nr_flushers), + (int) ATOMIC_GET(&lg->nr_open_files)); + printf("number of catalog entries "BUNFMT", of which "BUNFMT" deleted\n", + lg->catalog_bid->batCount, lg->dcatalog->batCount); + int npend = 0; + for (logged_range *p = lg->pending; p; p = p->next) + npend++; + if (npend > 1) + printf("number of pending ranges %d\n", npend); +} diff --git a/gdk/gdk_logger.h b/gdk/gdk_logger.h --- a/gdk/gdk_logger.h +++ b/gdk/gdk_logger.h @@ -78,4 +78,6 @@ gdk_export gdk_return log_tflush(logger gdk_export gdk_return log_tsequence(logger *lg, int seq, lng id); gdk_export log_bid log_find_bat(logger *lg, log_id id); +gdk_export void log_printinfo(logger *lg); + #endif /*_LOGGER_H_*/ diff --git a/gdk/gdk_utils.c b/gdk/gdk_utils.c --- a/gdk/gdk_utils.c +++ b/gdk/gdk_utils.c @@ -2031,6 +2031,27 @@ GDKmremap(const char *path, int mode, vo } /* print some potentially interesting information */ +struct prinfocb { + struct prinfocb *next; + void (*func)(void); +} *prinfocb; + +void +GDKprintinforegister(void (*func)(void)) +{ + struct prinfocb *p = GDKmalloc(sizeof(struct prinfocb)); + if (p == NULL) { + GDKerror("cannot register USR1 printing function.\n"); + return; + } + p->func = func; + p->next = NULL; + struct prinfocb **pp = &prinfocb; + while (*pp != NULL) + pp = &(*pp)->next; + *pp = p; +} + void GDKprintinfo(void) { @@ -2064,4 +2085,6 @@ GDKprintinfo(void) GDKlockstatistics(3); #endif dump_threads(); + for (struct prinfocb *p = prinfocb; p; p = p->next) + (*p->func)(); } diff --git a/gdk/gdk_utils.h b/gdk/gdk_utils.h --- a/gdk/gdk_utils.h +++ b/gdk/gdk_utils.h @@ -13,6 +13,7 @@ #include <setjmp.h> +gdk_export void GDKprintinforegister(void (*func)(void)); gdk_export void GDKprintinfo(void); gdk_export const char *GDKgetenv(const char *name); diff --git a/monetdb5/mal/mal.c b/monetdb5/mal/mal.c --- a/monetdb5/mal/mal.c +++ b/monetdb5/mal/mal.c @@ -51,6 +51,12 @@ mal_version(void) return MONETDB5_VERSION; } +static void +MALprintinfo(void) +{ + /* we need to start printing MAL info here... */ +} + /* * Initialization of the MAL context */ @@ -91,6 +97,8 @@ mal_init(char *modules[], bool embedded, return -1; initNamespace(); + GDKprintinforegister(MALprintinfo); + err = malBootstrap(modules, embedded, initpasswd); if (err !=MAL_SUCCEED) { mal_client_reset(); diff --git a/monetdb5/mal/mal_instruction.c b/monetdb5/mal/mal_instruction.c --- a/monetdb5/mal/mal_instruction.c +++ b/monetdb5/mal/mal_instruction.c @@ -474,7 +474,7 @@ newInstruction(MalBlkPtr mb, const char } InstrPtr -copyInstructionArgs(InstrPtr p, int args) +copyInstructionArgs(const InstrRecord *p, int args) { if (args < p->maxarg) args = p->maxarg; @@ -493,7 +493,7 @@ copyInstructionArgs(InstrPtr p, int args } InstrPtr _______________________________________________ checkin-list mailing list -- checkin-list@monetdb.org To unsubscribe send an email to checkin-list-le...@monetdb.org