Changeset: ad06435f93de for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/ad06435f93de Modified Files: .hgtags gdk/gdk_bat.c gdk/gdk_bbp.c Branch: Jan2022 Log Message:
Merge with Jul2021 branch. diffs (115 lines): diff --git a/.hgtags b/.hgtags --- a/.hgtags +++ b/.hgtags @@ -786,3 +786,4 @@ 8a95168e853382b9b89ac7b67e343788ea837f3a 8a95168e853382b9b89ac7b67e343788ea837f3a Jul2021_SP9_release 24385ee6130494440e09d31ec73f4aa2e2893e98 Jul2021_33 05b3d9ea9165baf1d2956d5b06ad85f817ecc6d2 Jul2021_33 +05b3d9ea9165baf1d2956d5b06ad85f817ecc6d2 Jul2021_SP10_release diff --git a/gdk/gdk_bat.c b/gdk/gdk_bat.c --- a/gdk/gdk_bat.c +++ b/gdk/gdk_bat.c @@ -657,9 +657,6 @@ BATfree(BAT *b) return; /* deallocate all memory for a bat */ - if (b->tident && !default_ident(b->tident)) - GDKfree(b->tident); - b->tident = BATstring_t; MT_rwlock_rdlock(&b->thashlock); BUN nunique = BUN_NONE; if (b->thash && b->thash != (Hash *) 1) { @@ -671,6 +668,9 @@ BATfree(BAT *b) OIDXfree(b); STRMPfree(b); MT_lock_set(&b->theaplock); + if (b->tident && !default_ident(b->tident)) + GDKfree(b->tident); + b->tident = BATstring_t; if (nunique != BUN_NONE) { b->tunique_est = (double) nunique; } @@ -2054,12 +2054,14 @@ BATroles(BAT *b, const char *tnme) { if (b == NULL) return GDK_SUCCEED; + MT_lock_set(&b->theaplock); if (b->tident && !default_ident(b->tident)) GDKfree(b->tident); if (tnme) b->tident = GDKstrdup(tnme); else b->tident = BATstring_t; + MT_lock_unset(&b->theaplock); return b->tident ? GDK_SUCCEED : GDK_FAIL; } diff --git a/gdk/gdk_bbp.c b/gdk/gdk_bbp.c --- a/gdk/gdk_bbp.c +++ b/gdk/gdk_bbp.c @@ -2979,12 +2979,24 @@ decref(bat i, bool logical, bool release GDKerror("%s: %s does not have pointer fixes.\n", func, BBP_logical(i)); assert(0); } else { - assert(b == NULL || b->theap == NULL || BBP_refs(b->theap->parentid) > 0); - assert(b == NULL || b->tvheap == NULL || BBP_refs(b->tvheap->parentid) > 0); +#ifndef NDEBUG + if (b) { + MT_lock_set(&b->theaplock); + locked = true; + assert(b->theap == NULL || BBP_refs(b->theap->parentid) > 0); + assert(b->tvheap == NULL || BBP_refs(b->tvheap->parentid) > 0); + } +#endif refs = --BBP_refs(i); if (b && refs == 0) { +#ifdef NDEBUG + /* if NDEBUG is not defined, we locked + * the heaplock above, so we only lock + * it here if NDEBUG *is* defined */ MT_lock_set(&b->theaplock); locked = true; +#endif + assert(locked); /* just to be clear */ tp = VIEWtparent(b); tvp = VIEWvtparent(b); if (tp || tvp) @@ -2993,8 +3005,10 @@ decref(bat i, bool logical, bool release } } if (b) { - if (!locked) + if (!locked) { MT_lock_set(&b->theaplock); + locked = true; + } if (b->batCount > b->batInserted && !isVIEW(b)) { /* if batCount is larger than batInserted and * the dirty bits are off, it may be that a @@ -3013,9 +3027,14 @@ decref(bat i, bool logical, bool release /* we destroy transients asap and unload persistent bats only * if they have been made cold or are not dirty */ unsigned chkflag = BBPSYNCING; - if (GDKvm_cursize() < GDK_vm_maxsize && - ((b && b->theap ? b->theap->size : 0) + (b && b->tvheap ? b->tvheap->size : 0)) < (GDK_vm_maxsize - GDKvm_cursize()) / 32) - chkflag |= BBPHOT; + if (b && GDKvm_cursize() < GDK_vm_maxsize) { + if (!locked) { + MT_lock_set(&b->theaplock); + locked = true; + } + if (((b->theap ? b->theap->size : 0) + (b->tvheap ? b->tvheap->size : 0)) < (GDK_vm_maxsize - GDKvm_cursize()) / 32) + chkflag |= BBPHOT; + } /* only consider unloading if refs is 0; if, in addition, lrefs * is 0, we can definitely unload, else only if some more * conditions are met */ @@ -3041,7 +3060,7 @@ decref(bat i, bool logical, bool release swap = true; } /* else: bat cannot be swapped out */ lrefs = BBP_lrefs(i); - if (b) + if (locked) MT_lock_unset(&b->theaplock); /* unlock before re-locking in unload; as saving a dirty _______________________________________________ checkin-list mailing list -- checkin-list@monetdb.org To unsubscribe send an email to checkin-list-le...@monetdb.org