Changeset: 1dae32253a07 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/1dae32253a07
Modified Files:
gdk/gdk_align.c
gdk/gdk_bat.c
gdk/gdk_batop.c
gdk/gdk_hash.c
gdk/gdk_heap.c
gdk/gdk_orderidx.c
gdk/gdk_string.c
sql/server/rel_optimize_proj.c
sql/server/rel_optimize_sel.c
Branch: default
Log Message:
merged with aug2024
diffs (truncated from 525 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
@@ -317,7 +317,6 @@ BATmaterialize(BAT *b, BUN cap)
h = b->theap;
b->theap = tail;
b->tbaseoff = 0;
- b->theap->dirty = true;
b->tunique_est = is_oid_nil(t) ? 1.0 : (double) b->batCount;
b->ttype = TYPE_oid;
BATsetdims(b, 0);
diff --git a/gdk/gdk_bat.c b/gdk/gdk_bat.c
--- a/gdk/gdk_bat.c
+++ b/gdk/gdk_bat.c
@@ -791,24 +791,24 @@ COLcopy(BAT *b, int tt, bool writable, r
oid cur = bi.tseq, *dst = (oid *) Tloc(bn, 0);
const oid inc = !is_oid_nil(cur);
- bn->theap->free = bi.count * sizeof(oid);
- bn->theap->dirty |= bi.count > 0;
for (BUN p = 0; p < bi.count; p++) {
dst[p] = cur;
cur += inc;
}
+ bn->theap->free = bi.count * sizeof(oid);
+ bn->theap->dirty |= bi.count > 0;
} else if (ATOMstorage(bi.type) == TYPE_msk) {
/* convert number of bits to number of bytes,
* and round the latter up to a multiple of
* 4 (copy in units of 4 bytes) */
bn->theap->free = ((bi.count + 31) / 32) * 4;
+ memcpy(Tloc(bn, 0), bi.base, bn->theap->free);
bn->theap->dirty |= bi.count > 0;
- memcpy(Tloc(bn, 0), bi.base, bn->theap->free);
} else {
/* case (4): optimized for simple array copy */
bn->theap->free = bi.count << bn->tshift;
+ memcpy(Tloc(bn, 0), bi.base, bn->theap->free);
bn->theap->dirty |= bi.count > 0;
- memcpy(Tloc(bn, 0), bi.base, bn->theap->free);
}
/* copy all properties (size+other) from the source bat */
BATsetcount(bn, bi.count);
diff --git a/gdk/gdk_batop.c b/gdk/gdk_batop.c
--- a/gdk/gdk_batop.c
+++ b/gdk/gdk_batop.c
@@ -511,7 +511,6 @@ append_msk_bat(BAT *b, BATiter *ni, stru
uint32_t boff = b->batCount % 32;
uint32_t *bp = (uint32_t *) b->theap->base + b->batCount / 32;
b->batCount += ci->ncand;
- b->theap->dirty = true;
b->theap->free = ((b->batCount + 31) / 32) * 4;
if (ci->tpe == cand_dense) {
const uint32_t *np;
@@ -664,6 +663,7 @@ append_msk_bat(BAT *b, BATiter *ni, stru
boff = 0;
} while (!is_oid_nil(o));
}
+ b->theap->dirty = true;
MT_lock_unset(&b->theaplock);
return GDK_SUCCEED;
}
diff --git a/gdk/gdk_hash.c b/gdk/gdk_hash.c
--- a/gdk/gdk_hash.c
+++ b/gdk/gdk_hash.c
@@ -345,8 +345,6 @@ HASHgrowbucket(BAT *b)
HASHupgradehashheap(b) != GDK_SUCCEED)
return GDK_FAIL;
- h->heapbckt.dirty = true;
- h->heaplink.dirty = true;
while (h->nunique >= (nbucket = h->nbucket) * 7 / 8) {
BUN new = h->nbucket;
BUN old = new & h->mask1;
@@ -413,6 +411,8 @@ HASHgrowbucket(BAT *b)
else
HASHputlink(h, lold, BUN_NONE);
}
+ h->heapbckt.dirty = true;
+ h->heaplink.dirty = true;
TRC_DEBUG_IF(ACCELERATOR) if (h->nbucket > onbucket) {
TRC_DEBUG_ENDIF(ACCELERATOR, ALGOBATFMT " " BUNFMT
" -> " BUNFMT " buckets (" LLFMT " usec)\n",
@@ -510,8 +510,6 @@ BATcheckhash(BAT *b)
h->Bckt =
h->heapbckt.base + HASH_HEADER_SIZE * SIZEOF_SIZE_T;
h->heaplink.parentid = b->batCacheid;
h->heapbckt.parentid = b->batCacheid;
-
h->heaplink.dirty = false;
-
h->heapbckt.dirty = false;
b->thash = h;
h->heapbckt.hasfile = true;
h->heaplink.hasfile = true;
@@ -611,16 +609,20 @@ BAThashsave_intern(BAT *b, bool dosync)
* mean time */
if (!b->theap->dirty &&
((size_t *) h->heapbckt.base)[1] == BATcount(b) &&
- ((size_t *) h->heapbckt.base)[4] == BATcount(b) &&
- HEAPsave(&h->heaplink, h->heaplink.filename, NULL, dosync,
h->heaplink.free, NULL) == GDK_SUCCEED &&
- HEAPsave(&h->heapbckt, h->heapbckt.filename, NULL, dosync,
h->heapbckt.free, NULL) == GDK_SUCCEED) {
+ ((size_t *) h->heapbckt.base)[4] == BATcount(b)) {
h->heaplink.dirty = false;
h->heapbckt.dirty = false;
- h->heaplink.hasfile = true;
- h->heapbckt.hasfile = true;
- gdk_return rc = HASHfix(h, true, dosync);
- TRC_DEBUG(ACCELERATOR,
- ALGOBATFMT ": persisting hash %s%s (" LLFMT "
usec)%s\n", ALGOBATPAR(b), h->heapbckt.filename, dosync ? "" : " no sync",
GDKusec() - t0, rc == GDK_SUCCEED ? "" : " failed");
+ if (HEAPsave(&h->heaplink, h->heaplink.filename, NULL,
dosync, h->heaplink.free, NULL) == GDK_SUCCEED &&
+ HEAPsave(&h->heapbckt, h->heapbckt.filename, NULL,
dosync, h->heapbckt.free, NULL) == GDK_SUCCEED) {
+ h->heaplink.hasfile = true;
+ h->heapbckt.hasfile = true;
+ gdk_return rc = HASHfix(h, true, dosync);
+ TRC_DEBUG(ACCELERATOR,
+ ALGOBATFMT ": persisting hash %s%s ("
LLFMT " usec)%s\n", ALGOBATPAR(b), h->heapbckt.filename, dosync ? "" : " no
sync", GDKusec() - t0, rc == GDK_SUCCEED ? "" : " failed");
+ } else {
+ h->heaplink.dirty = true;
+ h->heapbckt.dirty = true;
+ }
}
GDKclrerr();
}
@@ -1181,10 +1183,10 @@ HASHinsert_locked(BATiter *bi, BUN p, co
if (hb == BUN_NONE || hb < p) {
/* bucket is empty, or bucket is used by lower numbered
* position */
+ HASHputlink(h, p, hb);
+ HASHput(h, c, p);
h->heaplink.dirty = true;
h->heapbckt.dirty = true;
- HASHputlink(h, p, hb);
- HASHput(h, c, p);
if (hb == BUN_NONE) {
h->nheads++;
} else {
@@ -1208,9 +1210,9 @@ HASHinsert_locked(BATiter *bi, BUN p, co
seen = atomcmp(v, BUNtail(*bi, hb)) == 0;
BUN hb2 = HASHgetlink(h, hb);
if (hb2 == BUN_NONE || hb2 < p) {
- h->heaplink.dirty = true;
HASHputlink(h, p, hb2);
HASHputlink(h, hb, p);
+ h->heaplink.dirty = true;
while (!seen && hb2 != BUN_NONE) {
seen = atomcmp(v, BUNtail(*bi, hb2)) == 0;
hb2 = HASHgetlink(h, hb2);
@@ -1267,10 +1269,10 @@ HASHdelete_locked(BATiter *bi, BUN p, co
int (*atomcmp)(const void *, const void *) = ATOMcompare(h->type);
if (hb == p) {
BUN hb2 = HASHgetlink(h, p);
+ HASHput(h, c, hb2);
+ HASHputlink(h, p, BUN_NONE);
h->heaplink.dirty = true;
h->heapbckt.dirty = true;
- HASHput(h, c, hb2);
- HASHputlink(h, p, BUN_NONE);
if (hb2 == BUN_NONE) {
h->nheads--;
} else {
@@ -1312,9 +1314,9 @@ HASHdelete_locked(BATiter *bi, BUN p, co
return;
}
}
- h->heaplink.dirty = true;
HASHputlink(h, hb, HASHgetlink(h, p));
HASHputlink(h, p, BUN_NONE);
+ h->heaplink.dirty = true;
if (!seen)
h->nunique--;
}
diff --git a/gdk/gdk_heap.c b/gdk/gdk_heap.c
--- a/gdk/gdk_heap.c
+++ b/gdk/gdk_heap.c
@@ -798,6 +798,7 @@ HEAPload(Heap *h, const char *nme, const
return GDK_FAIL;
}
}
+ h->dirty = false; /* we're about to read it, so it's clean */
if (h->storage == STORE_MEM && h->free == 0) {
h->base = GDKmalloc(h->size);
h->wasempty = true;
@@ -816,7 +817,6 @@ HEAPload(Heap *h, const char *nme, const
return GDK_FAIL; /* file could not be read satisfactorily */
}
- h->dirty = false; /* we just read it, so it's clean */
return GDK_SUCCEED;
}
@@ -1098,7 +1098,6 @@ HEAP_malloc(BAT *b, size_t nbytes)
}
heap = b->tvheap;
heap->free = newsize;
- heap->dirty = true;
hheader = HEAP_index(heap, 0, HEADER);
blockp = HEAP_index(heap, block, CHUNK);
@@ -1146,6 +1145,8 @@ HEAP_malloc(BAT *b, size_t nbytes)
trailp->next = blockp->next;
}
+ heap->dirty = true;
+
block += hheader->alignment;
return (var_t) block;
}
diff --git a/gdk/gdk_orderidx.c b/gdk/gdk_orderidx.c
--- a/gdk/gdk_orderidx.c
+++ b/gdk/gdk_orderidx.c
@@ -43,8 +43,8 @@ BATidxsync(void *arg)
fsync(fd);
#endif
}
- hp->dirty = false;
} else {
+ hp->dirty = true;
perror("write hash");
}
close(fd);
@@ -53,9 +53,9 @@ BATidxsync(void *arg)
((oid *) hp->base)[0] |= (oid) 1 << 24;
if (!(ATOMIC_GET(&GDKdebug) & NOSYNCMASK) &&
MT_msync(hp->base, SIZEOF_OID) < 0) {
+ hp->dirty = true;
((oid *) hp->base)[0] &= ~((oid) 1 <<
24);
} else {
- hp->dirty = false;
failed = ""; /* not failed */
}
}
diff --git a/gdk/gdk_strimps.c b/gdk/gdk_strimps.c
--- a/gdk/gdk_strimps.c
+++ b/gdk/gdk_strimps.c
@@ -646,8 +646,8 @@ BATstrimpsync(BAT *b)
fsync(fd);
#endif
}
- hp->dirty = false;
} else {
+ hp->dirty = true;
perror("write strimps");
}
close(fd);
@@ -656,9 +656,9 @@ BATstrimpsync(BAT *b)
((uint64_t *)hp->base)[0] |= (uint64_t) 1 << 32;
if (!(ATOMIC_GET(&GDKdebug) & NOSYNCMASK) &&
MT_msync(hp->base, sizeof(uint64_t)) < 0) {
+ hp->dirty = true;
((uint64_t *)hp->base)[0] &=
~((uint64_t) 1 << 32);
} else {
- hp->dirty = false;
failed = "";
}
}
diff --git a/gdk/gdk_string.c b/gdk/gdk_string.c
--- a/gdk/gdk_string.c
+++ b/gdk/gdk_string.c
@@ -125,11 +125,11 @@ strCleanHash(Heap *h, bool rebuild)
/* only set dirty flag if the hash table actually changed */
if (memcmp(newhash, h->base, sizeof(newhash)) != 0) {
memcpy(h->base, newhash, sizeof(newhash));
- if (h->storage == STORE_MMAP) {
- if (!(ATOMIC_GET(&GDKdebug) & NOSYNCMASK))
- (void) MT_msync(h->base, GDK_STRHASHSIZE);
- } else
+ if (h->storage != STORE_MMAP ||
+ ATOMIC_GET(&GDKdebug) & NOSYNCMASK ||
+ MT_msync(h->base, GDK_STRHASHSIZE) < 0) {
h->dirty = true;
+ }
}
#ifndef NDEBUG
if (GDK_ELIMDOUBLES(h)) {
@@ -198,13 +198,13 @@ strPut(BAT *b, var_t *dst, const void *V
h = b->tvheap;
}
h->free = GDK_STRHASHTABLE * sizeof(stridx_t);
- h->dirty = true;
#ifdef NDEBUG
memset(h->base, 0, h->free);
#else
/* fill should solve initialization problems within valgrind */
memset(h->base, 0, h->size);
#endif
+ h->dirty = true;
b->tascii = true;
}
@@ -301,7 +301,6 @@ strPut(BAT *b, var_t *dst, const void *V
memset(h->base + h->free, 0, pad);
memcpy(h->base + pos, v, len);
h->free += pad + len;
- h->dirty = true;
/* maintain hash table */
if (GDK_ELIMBASE(pos) == 0) { /* small string heap: link the next
pointer */
@@ -311,6 +310,7 @@ strPut(BAT *b, var_t *dst, const void *V
*(stridx_t *) (h->base + pos) = *bucket;
}
*bucket = (stridx_t) pos; /* set bucket to the new string */
+ h->dirty = true;
_______________________________________________
checkin-list mailing list -- [email protected]
To unsubscribe send an email to [email protected]