Changeset: f2a0639e1fc7 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB/rev/f2a0639e1fc7 Modified Files: gdk/gdk_align.c gdk/gdk_bat.c gdk/gdk_batop.c gdk/gdk_bbp.c gdk/gdk_delta.c gdk/gdk_tm.c Branch: Jan2022 Log Message:
Merge with Jul2021 branch. diffs (truncated from 339 to 300 lines): diff --git a/gdk/gdk_align.c b/gdk/gdk_align.c --- a/gdk/gdk_align.c +++ b/gdk/gdk_align.c @@ -253,11 +253,11 @@ BATmaterialize(BAT *b) b->tbaseoff = 0; b->theap->dirty = true; b->tunique_est = is_oid_nil(t) ? 1.0 : (double) b->batCount; - MT_lock_unset(&b->theaplock); b->ttype = TYPE_oid; BATsetdims(b, 0); b->batDirtydesc = true; BATsetcount(b, b->batCount); + MT_lock_unset(&b->theaplock); return GDK_SUCCEED; } diff --git a/gdk/gdk_bat.c b/gdk/gdk_bat.c --- a/gdk/gdk_bat.c +++ b/gdk/gdk_bat.c @@ -97,6 +97,7 @@ BATcreatedesc(oid hseq, int tt, bool hea .batRole = role, .batTransient = true, .batRestricted = BAT_WRITE, + .batDirtydesc = true, }; if (heapnames && (bn->theap = GDKmalloc(sizeof(Heap))) == NULL) { GDKfree(bn); @@ -120,6 +121,7 @@ BATcreatedesc(oid hseq, int tt, bool hea *bn->theap = (Heap) { .parentid = bn->batCacheid, .farmid = BBPselectfarm(role, bn->ttype, offheap), + .dirty = true, }; const char *nme = BBP_physical(bn->batCacheid); @@ -136,6 +138,7 @@ BATcreatedesc(oid hseq, int tt, bool hea *bn->tvheap = (Heap) { .parentid = bn->batCacheid, .farmid = BBPselectfarm(role, bn->ttype, varheap), + .dirty = true, }; ATOMIC_INIT(&bn->tvheap->refs, 1); strconcat_len(bn->tvheap->filename, @@ -153,7 +156,6 @@ BATcreatedesc(oid hseq, int tt, bool hea MT_lock_init(&bn->batIdxLock, name); snprintf(name, sizeof(name), "hashlock%d", bn->batCacheid); /* fits */ MT_rwlock_init(&bn->thashlock, name); - bn->batDirtydesc = true; return bn; } @@ -630,6 +632,7 @@ BATclear(BAT *b, bool force) b->batCount = 0; if (b->ttype == TYPE_void) b->batCapacity = 0; + b->theap->free = 0; BAThseqbase(b, 0); BATtseqbase(b, ATOMtype(b->ttype) == TYPE_oid ? 0 : oid_nil); b->batDirtydesc = true; @@ -1022,9 +1025,11 @@ BUNappendmulti(BAT *b, const void *value } } if (dense) { + MT_lock_set(&b->theaplock); if (b->batCount == 0) b->tseqbase = ovals ? ovals[0] : oid_nil; BATsetcount(b, BATcount(b) + count); + MT_lock_unset(&b->theaplock); return GDK_SUCCEED; } else { /* we need to materialize b; allocate enough capacity */ @@ -1051,11 +1056,9 @@ BUNappendmulti(BAT *b, const void *value return rc; } - if (count > BATcount(b) / GDK_UNIQUE_ESTIMATE_KEEP_FRACTION) { - MT_lock_set(&b->theaplock); + MT_lock_set(&b->theaplock); + if (count > BATcount(b) / GDK_UNIQUE_ESTIMATE_KEEP_FRACTION) b->tunique_est = 0; - MT_lock_unset(&b->theaplock); - } b->theap->dirty = true; const void *t = b->ttype == TYPE_msk ? &(msk){false} : ATOMnilptr(b->ttype); if (b->ttype == TYPE_oid) { @@ -1152,6 +1155,7 @@ BUNappendmulti(BAT *b, const void *value b->tnonil = false; b->tsorted = b->trevsorted = b->tkey = false; } + MT_lock_unset(&b->theaplock); if (values && b->ttype) { int (*atomcmp) (const void *, const void *) = ATOMcompare(b->ttype); const void *atomnil = ATOMnilptr(b->ttype); @@ -1271,7 +1275,9 @@ BUNappendmulti(BAT *b, const void *value } MT_rwlock_wrunlock(&b->thashlock); } + MT_lock_set(&b->theaplock); BATsetcount(b, p); + MT_lock_unset(&b->theaplock); IMPSdestroy(b); /* no support for inserts in imprints yet */ OIDXdestroy(b); @@ -1868,7 +1874,6 @@ BATsetcount(BAT *b, BUN cnt) assert(!is_oid_nil(b->hseqbase)); assert(cnt <= BUN_MAX); - MT_lock_set(&b->theaplock); b->batCount = cnt; b->batDirtydesc = true; b->theap->dirty |= b->ttype != TYPE_void && b->theap->parentid == b->batCacheid && cnt > 0; @@ -1904,7 +1909,6 @@ BATsetcount(BAT *b, BUN cnt) } } assert(b->batCapacity >= cnt); - MT_lock_unset(&b->theaplock); } /* diff --git a/gdk/gdk_batop.c b/gdk/gdk_batop.c --- a/gdk/gdk_batop.c +++ b/gdk/gdk_batop.c @@ -151,6 +151,7 @@ insert_string_bat(BAT *b, BAT *n, struct } memcpy(b->tvheap->base + toff, ni.vh->base, ni.vhfree); b->tvheap->free = toff + ni.vhfree; + b->tvheap->dirty = true; } } } @@ -326,8 +327,10 @@ insert_string_bat(BAT *b, BAT *n, struct } bat_iterator_end(&ni); TIMEOUT_CHECK(timeoffset, TIMEOUT_HANDLER(GDK_FAIL)); + MT_lock_set(&b->theaplock); BATsetcount(b, oldcnt + ci->ncand); assert(b->batCapacity >= b->batCount); + MT_lock_unset(&b->theaplock); /* maintain hash */ MT_rwlock_wrlock(&b->thashlock); for (r = oldcnt, cnt = BATcount(b); b->thash && r < cnt; r++) { @@ -398,7 +401,9 @@ append_varsized_bat(BAT *b, BAT *n, stru *dst++ = src[canditer_next(ci) - hseq]; } } + MT_lock_set(&b->theaplock); BATsetcount(b, BATcount(b) + ci->ncand); + MT_lock_unset(&b->theaplock); /* maintain hash table */ MT_rwlock_wrlock(&b->thashlock); for (BUN i = BATcount(b) - ci->ncand; @@ -486,7 +491,9 @@ append_varsized_bat(BAT *b, BAT *n, stru } } MT_rwlock_wrunlock(&b->thashlock); + MT_lock_set(&b->theaplock); BATsetcount(b, r); + MT_lock_unset(&b->theaplock); bat_iterator_end(&ni); return GDK_SUCCEED; } @@ -723,12 +730,14 @@ BATappend2(BAT *b, BAT *n, BAT *s, bool return GDK_FAIL; } - b->batDirtydesc = true; - IMPSdestroy(b); /* imprints do not support updates yet */ OIDXdestroy(b); STRMPdestroy(b); /* TODO: use STRMPappendBitString */ + MT_lock_set(&b->theaplock); + + b->batDirtydesc = true; + if (BATcount(b) == 0 || b->tmaxpos != BUN_NONE) { if (ni.maxpos != BUN_NONE) { BATiter bi = bat_iterator_nolock(b); @@ -767,6 +776,7 @@ BATappend2(BAT *b, BAT *n, BAT *s, bool if (b->ttype == TYPE_void) { /* b does not have storage, keep it that way if we can */ HASHdestroy(b); /* we're not maintaining the hash here */ + MT_lock_set(&b->theaplock); if (BATtdense(n) && ci.tpe == cand_dense && (BATcount(b) == 0 || (BATtdense(b) && @@ -775,6 +785,7 @@ BATappend2(BAT *b, BAT *n, BAT *s, bool if (BATcount(b) == 0) BATtseqbase(b, n->tseqbase + ci.seq - hseq); BATsetcount(b, BATcount(b) + cnt); + MT_lock_unset(&b->theaplock); goto doreturn; } if ((BATcount(b) == 0 || is_oid_nil(b->tseqbase)) && @@ -782,10 +793,12 @@ BATappend2(BAT *b, BAT *n, BAT *s, bool /* both b and n are void/nil */ BATtseqbase(b, oid_nil); BATsetcount(b, BATcount(b) + cnt); + MT_lock_unset(&b->theaplock); goto doreturn; } /* we need to materialize b; allocate enough capacity */ b->batCapacity = BATcount(b) + cnt; + MT_lock_unset(&b->theaplock); if (BATmaterialize(b) != GDK_SUCCEED) { bat_iterator_end(&ni); return GDK_FAIL; @@ -795,6 +808,7 @@ BATappend2(BAT *b, BAT *n, BAT *s, bool r = BUNlast(b); /* property setting */ + MT_lock_set(&b->theaplock); if (BATcount(b) == 0) { b->tsorted = n->tsorted; b->trevsorted = n->trevsorted; @@ -848,6 +862,7 @@ BATappend2(BAT *b, BAT *n, BAT *s, bool b->tnonil &= n->tnonil; b->tnil |= n->tnil && cnt == ni.count; } + MT_lock_unset(&b->theaplock); if (b->ttype == TYPE_str) { if (insert_string_bat(b, n, &ci, force, mayshare, timeoffset) != GDK_SUCCEED) { bat_iterator_end(&ni); @@ -906,7 +921,9 @@ BATappend2(BAT *b, BAT *n, BAT *s, bool TIMEOUT_CHECK(timeoffset, GOTO_LABEL_TIMEOUT_HANDLER(bailout)); } MT_rwlock_wrunlock(&b->thashlock); + MT_lock_set(&b->theaplock); BATsetcount(b, b->batCount + ci.ncand); + MT_lock_unset(&b->theaplock); } doreturn: @@ -1142,19 +1159,18 @@ BATappend_or_update(BAT *b, BAT *p, cons return GDK_FAIL; } - BATiter bi = bat_iterator_nolock(b); - BATiter ni = bat_iterator(n); - OIDXdestroy(b); IMPSdestroy(b); STRMPdestroy(b); + /* load hash so that we can maintain it */ + (void) BATcheckhash(b); + BATiter ni = bat_iterator(n); MT_lock_set(&b->theaplock); if (ni.count > BATcount(b) / GDK_UNIQUE_ESTIMATE_KEEP_FRACTION) { b->tunique_est = 0; } - MT_lock_unset(&b->theaplock); - /* load hash so that we can maintain it */ - (void) BATcheckhash(b); + + BATiter bi = bat_iterator_nolock(b); b->tsorted = b->trevsorted = false; b->tnosorted = b->tnorevsorted = 0; @@ -1165,6 +1181,9 @@ BATappend_or_update(BAT *b, BAT *p, cons int (*atomcmp)(const void *, const void *) = ATOMcompare(b->ttype); const void *nil = ATOMnilptr(b->ttype); oid hseqend = b->hseqbase + BATcount(b); + + MT_lock_unset(&b->theaplock); + bool anynil = false; bool locked = false; @@ -2781,6 +2800,7 @@ PROPdestroy(BAT *b) b->tprops = NULL; while (p) { + /* only set dirty if a saved property is changed */ n = p->next; VALclear(&p->v); GDKfree(p); @@ -2847,7 +2867,6 @@ BATsetprop_nolock(BAT *b, enum prop_t id GDKclrerr(); p = NULL; } - b->batDirtydesc = true; return p ? &p->v : NULL; } diff --git a/gdk/gdk_bbp.c b/gdk/gdk_bbp.c --- a/gdk/gdk_bbp.c +++ b/gdk/gdk_bbp.c @@ -791,6 +791,7 @@ BBPreadEntries(FILE *fp, unsigned bbpver goto bailout; } } + bn->batDirtydesc = false; /* undo setting by BATsetprop_nolock */ BBP_refs(bid) = 0; BBP_lrefs(bid) = 1; /* any BAT we encounter here is persistent, so has a logical reference */ BBP_desc(bid) = bn; @@ -3970,7 +3971,8 @@ BBPsync(int cnt, bat *restrict subcommit BBP_status_on(i, BBPSAVING); if (lock) MT_lock_unset(&GDKswapLock(i)); - assert(size <= bi.count || size == BUN_NONE); _______________________________________________ checkin-list mailing list -- checkin-list@monetdb.org To unsubscribe send an email to checkin-list-le...@monetdb.org