Changeset: fef916e3f289 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/fef916e3f289
Modified Files:
monetdb5/modules/mal/remote.c
sql/backends/monet5/sql.c
sql/storage/bat/bat_storage.c
Branch: iso
Log Message:
Merged with Jul2021
diffs (truncated from 354 to 300 lines):
diff --git a/gdk/gdk.h b/gdk/gdk.h
--- a/gdk/gdk.h
+++ b/gdk/gdk.h
@@ -1713,7 +1713,7 @@ Tputvalue(BAT *b, BUN p, const void *v,
if (rc != GDK_SUCCEED)
return rc;
if (b->twidth < SIZEOF_VAR_T &&
- (b->twidth <= 2 ? d - GDK_VAROFFSET : d) >= ((size_t) 1 <<
(8 * b->twidth))) {
+ (b->twidth <= 2 ? d - GDK_VAROFFSET : d) >= ((size_t) 1 <<
(8 << b->tshift))) {
/* doesn't fit in current heap, upgrade it */
rc = GDKupgradevarheap(b, d, 0, copyall);
if (rc != GDK_SUCCEED)
@@ -1735,9 +1735,9 @@ Tputvalue(BAT *b, BUN p, const void *v,
break;
#endif
}
- } else if (b->ttype == TYPE_msk) {
- mskSetVal(b, p, * (msk *) v);
} else {
+ /* msk is handled by tfastins_nocheck, our only caller */
+ assert(b->ttype != TYPE_msk);
return ATOMputFIX(b->ttype, Tloc(b, p), v);
}
return GDK_SUCCEED;
@@ -1752,8 +1752,10 @@ tfastins_nocheck(BAT *b, BUN p, const vo
((uint32_t *) b->theap->base)[b->theap->free / 4] = 0;
b->theap->free += 4;
}
- } else
- b->theap->free += s;
+ mskSetVal(b, p, * (msk *) v);
+ return GDK_SUCCEED;
+ }
+ b->theap->free += s;
return Tputvalue(b, p, v, false);
}
@@ -1805,7 +1807,7 @@ tfastins_nocheckVAR(BAT *b, BUN p, const
if ((rc = ATOMputVAR(b, &d, v)) != GDK_SUCCEED)
return rc;
if (b->twidth < SIZEOF_VAR_T &&
- (b->twidth <= 2 ? d - GDK_VAROFFSET : d) >= ((size_t) 1 << (8 *
b->twidth))) {
+ (b->twidth <= 2 ? d - GDK_VAROFFSET : d) >= ((size_t) 1 << (8 <<
b->tshift))) {
/* doesn't fit in current heap, upgrade it */
rc = GDKupgradevarheap(b, d, 0, false);
if (rc != GDK_SUCCEED)
diff --git a/gdk/gdk_bat.c b/gdk/gdk_bat.c
--- a/gdk/gdk_bat.c
+++ b/gdk/gdk_bat.c
@@ -546,7 +546,7 @@ BATextend(BAT *b, BUN newcap)
newcap = (newcap + 31) & ~(BUN)31; /* round up to multiple of
32 */
theap_size = (size_t) (newcap / 8); /* in bytes */
} else {
- theap_size = (size_t) newcap * Tsize(b);
+ theap_size = (size_t) newcap << b->tshift;
}
b->batCapacity = newcap;
@@ -926,7 +926,7 @@ COLcopy(BAT *b, int tt, bool writable, r
memcpy(Tloc(bn, 0), bi.base, bn->theap->free);
} else {
/* case (4): optimized for simple array copy */
- bn->theap->free = bunstocopy * Tsize(bn);
+ bn->theap->free = bunstocopy << bn->tshift;
bn->theap->dirty |= bunstocopy > 0;
memcpy(Tloc(bn, 0), bi.base, bn->theap->free);
}
@@ -1162,20 +1162,32 @@ BUNappendmulti(BAT *b, const void *value
b->tsorted = b->trevsorted = b->tkey = false;
}
MT_rwlock_wrlock(&b->thashlock);
- for (BUN i = 0; i < count; i++) {
- if (values) {
- t = b->ttype && b->tvarsized ? ((void **) values)[i] :
- (void *) ((char *) values + i * Tsize(b));
+ if (values && b->ttype) {
+ for (BUN i = 0; i < count; i++) {
+ t = b->tvarsized ? ((void **) values)[i] :
+ (void *) ((char *) values + (i << b->tshift));
+ gdk_return rc = bunfastapp_nocheck(b, p, t, Tsize(b));
+ if (rc != GDK_SUCCEED) {
+ MT_rwlock_wrunlock(&b->thashlock);
+ return rc;
+ }
+ if (b->thash) {
+ HASHappend_locked(b, p, t);
+ }
+ p++;
}
- gdk_return rc = bunfastapp_nocheck(b, p, t, Tsize(b));
- if (rc != GDK_SUCCEED) {
- MT_rwlock_wrunlock(&b->thashlock);
- return rc;
+ } else {
+ for (BUN i = 0; i < count; i++) {
+ gdk_return rc = bunfastapp_nocheck(b, p, t, Tsize(b));
+ if (rc != GDK_SUCCEED) {
+ MT_rwlock_wrunlock(&b->thashlock);
+ return rc;
+ }
+ if (b->thash) {
+ HASHappend_locked(b, p, t);
+ }
+ p++;
}
- if (b->thash) {
- HASHappend_locked(b, p, t);
- }
- p++;
}
MT_rwlock_wrunlock(&b->thashlock);
@@ -1305,7 +1317,7 @@ BUNinplacemulti(BAT *b, const oid *posit
BUN p = autoincr ? positions[0] - b->hseqbase + i :
positions[i] - b->hseqbase;
const void *t = b->ttype && b->tvarsized ?
((const void **) values)[i] :
- (const void *) ((const char *) values + i * Tsize(b));
+ (const void *) ((const char *) values + (i <<
b->tshift));
val = BUNtail(bi, p); /* old value */
if (ATOMcmp(b->ttype, val, t) == 0)
@@ -1389,7 +1401,7 @@ BUNinplacemulti(BAT *b, const oid *posit
return GDK_FAIL;
}
if (b->twidth < SIZEOF_VAR_T &&
- (b->twidth <= 2 ? _d - GDK_VAROFFSET : _d) >=
((size_t) 1 << (8 * b->twidth))) {
+ (b->twidth <= 2 ? _d - GDK_VAROFFSET : _d) >=
((size_t) 1 << (8 << b->tshift))) {
/* doesn't fit in current heap, upgrade it */
if (GDKupgradevarheap(b, _d, 0, false) !=
GDK_SUCCEED) {
MT_rwlock_wrunlock(&b->thashlock);
diff --git a/gdk/gdk_batop.c b/gdk/gdk_batop.c
--- a/gdk/gdk_batop.c
+++ b/gdk/gdk_batop.c
@@ -1305,7 +1305,7 @@ BATappend_or_update(BAT *b, BAT *p, cons
return GDK_FAIL;
}
if (b->twidth < SIZEOF_VAR_T &&
- (b->twidth <= 2 ? d - GDK_VAROFFSET : d) >=
((size_t) 1 << (8 * b->twidth))) {
+ (b->twidth <= 2 ? d - GDK_VAROFFSET : d) >=
((size_t) 1 << (8 << b->tshift))) {
/* doesn't fit in current heap, upgrade it */
if (GDKupgradevarheap(b, d, 0, false) !=
GDK_SUCCEED) {
MT_rwlock_wrunlock(&b->thashlock);
@@ -1483,7 +1483,7 @@ BATappend_or_update(BAT *b, BAT *p, cons
BATrmprop(b, GDK_MIN_POS);
}
memcpy(Tloc(b, pos), ni.base,
- ni.count * b->twidth);
+ ni.count << b->tshift);
}
/* either we have a hash that was updated above, or we
* have no hash; we cannot have the case where there is
@@ -1775,7 +1775,7 @@ BATslice(BAT *b, BUN l, BUN h)
if (bn->ttype) {
BATiter bi = bat_iterator(b);
memcpy(Tloc(bn, 0), (const char *) bi.base + (p
<< bi.shift),
- (q - p) * Tsize(bn));
+ (q - p) << bn->tshift);
bat_iterator_end(&bi);
bn->theap->dirty = true;
}
@@ -1870,7 +1870,7 @@ BATkeyed(BAT *b)
return mskGetVal(b, 0) != mskGetVal(b, 1);
}
if (b->twidth < SIZEOF_BUN &&
- BATcount(b) > (BUN) 1 << (8 * b->twidth)) {
+ BATcount(b) > (BUN) 1 << (8 << b->tshift)) {
/* more rows than possible bit combinations in the atom */
assert(!b->tkey);
return false;
diff --git a/gdk/gdk_bbp.c b/gdk/gdk_bbp.c
--- a/gdk/gdk_bbp.c
+++ b/gdk/gdk_bbp.c
@@ -1297,7 +1297,7 @@ heap_entry(FILE *fp, BAT *b, BUN size)
if (free > bytes)
free = bytes;
} else if (b->twidth > 0 && free / b->twidth > size)
- free = size * b->twidth;
+ free = size << b->tshift;
}
return fprintf(fp, " %s %d %d %d " BUNFMT " " BUNFMT " " BUNFMT " "
BUNFMT " " OIDFMT " %zu %zu %d " OIDFMT " " OIDFMT,
diff --git a/gdk/gdk_logger.c b/gdk/gdk_logger.c
--- a/gdk/gdk_logger.c
+++ b/gdk/gdk_logger.c
@@ -2519,6 +2519,7 @@ log_bat_transient(logger *lg, log_id id)
if (lg->debug & 1)
fprintf(stderr, "#Logged destroyed bat (%d) %d\n", id,
bid);
+ lg->end += BATcount(BBPquickdesc(bid, true));
gdk_return r = logger_del_bat(lg, bid);
logger_unlock(lg);
return r;
@@ -2642,7 +2643,7 @@ new_logfile(logger *lg)
p = (lng) getfilepos(getFile(lg->output_log));
if (p == -1)
return GDK_FAIL;
- if (p > log_large) {
+ if (p > log_large || (lg->end*1024) > log_large) {
lg->id++;
logger_close_output(lg);
return logger_open_output(lg);
diff --git a/gdk/gdk_project.c b/gdk/gdk_project.c
--- a/gdk/gdk_project.c
+++ b/gdk/gdk_project.c
@@ -414,7 +414,7 @@ project_str(BAT *restrict l, struct cand
bn->tvheap->free = h1off + r2i->vh->free;
}
- if (v >= ((var_t) 1 << (8 * bn->twidth)) &&
+ if (v >= ((var_t) 1 << (8 << bn->tshift)) &&
GDKupgradevarheap(bn, v, false, false) != GDK_SUCCEED) {
BBPreclaim(bn);
return NULL;
diff --git a/gdk/gdk_string.c b/gdk/gdk_string.c
--- a/gdk/gdk_string.c
+++ b/gdk/gdk_string.c
@@ -262,8 +262,8 @@ strPut(BAT *b, var_t *dst, const void *V
BUN off, strhash;
if (h->free == 0) {
- if (h->size < 64 * 1024) {
- if (HEAPgrow(&b->theaplock, &b->tvheap, 64 * 1024,
true) != GDK_SUCCEED) {
+ if (h->size < GDK_STRHASHTABLE * sizeof(stridx_t) + BATTINY *
GDK_VARALIGN) {
+ if (HEAPgrow(&b->theaplock, &b->tvheap,
GDK_STRHASHTABLE * sizeof(stridx_t) + BATTINY * GDK_VARALIGN, true) !=
GDK_SUCCEED) {
return 0;
}
h = b->tvheap;
diff --git a/monetdb5/mal/mal_profiler.c b/monetdb5/mal/mal_profiler.c
--- a/monetdb5/mal/mal_profiler.c
+++ b/monetdb5/mal/mal_profiler.c
@@ -381,7 +381,7 @@ renderProfilerEvent(Client cntxt, MalBlk
GDKfree(cv);
if (!ok)
return;
- total += cnt * d->twidth;
+ total += cnt << d->tshift;
if (!logadd(&logbuf, ",\"width\":%d",
d->twidth))
return;
/* keeping information about the
individual auxiliary heaps is helpful during analysis. */
diff --git a/monetdb5/mal/mal_resource.c b/monetdb5/mal/mal_resource.c
--- a/monetdb5/mal/mal_resource.c
+++ b/monetdb5/mal/mal_resource.c
@@ -73,7 +73,7 @@ getMemoryClaim(MalBlkPtr mb, MalStkPtr s
}
/* calculate the basic scan size */
- total += BATcount(b) * b->twidth;
+ total += BATcount(b) << b->tshift;
total += heapinfo(b->tvheap, b->batCacheid);
/* indices should help, find their maximum footprint */
diff --git a/monetdb5/mal/mal_runtime.c b/monetdb5/mal/mal_runtime.c
--- a/monetdb5/mal/mal_runtime.c
+++ b/monetdb5/mal/mal_runtime.c
@@ -447,7 +447,7 @@ getBatSpace(BAT *b){
lng space=0;
if( b == NULL)
return 0;
- space += BATcount(b) * b->twidth;
+ space += BATcount(b) << b->tshift;
if( space){
if( b->tvheap) space += heapinfo(b->tvheap, b->batCacheid);
space += hashinfo(b->thash, b->batCacheid);
diff --git a/monetdb5/modules/mal/remote.c b/monetdb5/modules/mal/remote.c
--- a/monetdb5/modules/mal/remote.c
+++ b/monetdb5/modules/mal/remote.c
@@ -1541,7 +1541,7 @@ static str RMTbincopyto(Client cntxt, Ma
v->tnonil,
BATtdense(v),
v->batCount,
- (size_t)v->batCount * Tsize(v),
+ (size_t)v->batCount << v->tshift,
sendtheap && v->batCount > 0 ? v->tvheap->free : 0
);
diff --git a/sql/backends/monet5/sql.c b/sql/backends/monet5/sql.c
--- a/sql/backends/monet5/sql.c
+++ b/sql/backends/monet5/sql.c
@@ -4002,7 +4002,7 @@ sql_storage(Client cntxt, MalBlkPtr mb,
if
(BUNappend(atom, &w, false) != GDK_SUCCEED)
goto
bailout;
- sz =
BATcount(bs) * bn->twidth;
+ sz =
BATcount(bs) << bn->tshift;
if
(BUNappend(size, &sz, false) != GDK_SUCCEED)
goto
bailout;
diff --git a/sql/backends/monet5/sql_result.c b/sql/backends/monet5/sql_result.c
--- a/sql/backends/monet5/sql_result.c
+++ b/sql/backends/monet5/sql_result.c
@@ -849,7 +849,7 @@ mvc_export_binary_bat(stream *s, BAT* bn
bn->tnonil,
BATtdense(bn),
bn->batCount,
- (size_t)bn->batCount * Tsize(bn),
+ (size_t)bn->batCount << bn->tshift,
sendtheap && bn->batCount > 0 ?
bn->tvheap->free : 0
);
diff --git a/sql/benchmarks/tpcds/Tests/one.test.in
b/sql/benchmarks/tpcds/Tests/one.test.in
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list