Changeset: 751ee163c711 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/751ee163c711
Modified Files:
monetdb5/mal/mal_profiler.c
monetdb5/mal/mal_runtime.c
monetdb5/modules/mal/batExtensions.c
monetdb5/modules/mal/groupby.c
monetdb5/modules/mal/mal_io.c
sql/backends/monet5/sql.c
sql/test/emptydb/Tests/check.stable.out.32bit
Branch: default
Log Message:
Merged with Jul2021
diffs (truncated from 679 to 300 lines):
diff --git a/gdk/gdk_tm.c b/gdk/gdk_tm.c
--- a/gdk/gdk_tm.c
+++ b/gdk/gdk_tm.c
@@ -63,9 +63,11 @@ prelude(int cnt, bat *restrict subcommit
return GDK_FAIL;
}
if (b) {
+ MT_lock_set(&b->theaplock);
assert(!isVIEW(b));
assert(b->batRole == PERSISTENT);
BATcommit(b, sizes ? sizes[i] : BUN_NONE);
+ MT_lock_unset(&b->theaplock);
}
}
}
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
@@ -954,13 +954,17 @@ getDiskSpace(void)
b = BATdescriptor(i);
if (b) {
size += sizeof(BAT);
+
+ MT_lock_set(&b->theaplock);
if (!isVIEW(b)) {
BUN cnt = BATcount(b);
- size += tailsize(b, cnt);
/* the upperbound is used for the heaps
*/
if (b->tvheap)
size += HEAPvmsize(b->tvheap);
+ MT_lock_unset(&b->theaplock);
+
+ size += tailsize(b, cnt);
if (b->thash)
size += sizeof(BUN) * cnt;
/* also add the size of an imprint,
ordered index or mosaic */
@@ -968,6 +972,8 @@ getDiskSpace(void)
size += IMPSimprintsize(b);
if(b->torderidx)
size +=
HEAPvmsize(b->torderidx);
+ } else {
+ MT_lock_unset(&b->theaplock);
}
BBPunfix(i);
}
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
@@ -464,7 +464,9 @@ getBatSpace(BAT *b){
return 0;
space += BATcount(b) << b->tshift;
if( space){
+ MT_lock_set(&b->theaplock);
if( b->tvheap) space += heapinfo(b->tvheap, b->batCacheid);
+ MT_lock_unset(&b->theaplock);
MT_rwlock_rdlock(&b->thashlock);
space += hashinfo(b->thash, b->batCacheid);
MT_rwlock_rdunlock(&b->thashlock);
diff --git a/monetdb5/modules/kernel/algebra.c
b/monetdb5/modules/kernel/algebra.c
--- a/monetdb5/modules/kernel/algebra.c
+++ b/monetdb5/modules/kernel/algebra.c
@@ -1099,7 +1099,7 @@ ALGsubslice_lng(bat *ret, const bat *bid
if (*start < 0 || *start > (lng) BUN_MAX ||
(*end < 0 && !is_lng_nil(*end)) || *end >= (lng) BUN_MAX)
throw(MAL, "algebra.subslice", ILLEGAL_ARGUMENT);
- if ((b = BATdescriptor(*bid)) == NULL)
+ if ((b = BBPquickdesc(*bid)) == NULL)
throw(MAL, "algebra.subslice", SQLSTATE(HY002)
RUNTIME_OBJECT_MISSING);
s = (BUN) *start;
if (s > BATcount(b))
@@ -1110,7 +1110,6 @@ ALGsubslice_lng(bat *ret, const bat *bid
if (e < s)
e = s;
bn = BATdense(0, b->hseqbase + s, e - s);
- BBPunfix(*bid);
if (bn == NULL)
throw(MAL, "algebra.subslice", SQLSTATE(HY013) MAL_MALLOC_FAIL);
*ret = bn->batCacheid;
diff --git a/monetdb5/modules/kernel/bat5.c b/monetdb5/modules/kernel/bat5.c
--- a/monetdb5/modules/kernel/bat5.c
+++ b/monetdb5/modules/kernel/bat5.c
@@ -572,14 +572,20 @@ BKCgetSize(lng *tot, const bat *bid){
}
size = sizeof (bat);
+
+ MT_lock_set(&b->theaplock);
if ( !isVIEW(b)) {
BUN cnt = BATcapacity(b);
size += ROUND_UP(b->theap->free, blksize);
if (b->tvheap)
size += ROUND_UP(b->tvheap->free, blksize);
+ MT_lock_unset(&b->theaplock);
+
if (b->thash)
size += ROUND_UP(sizeof(BUN) * cnt, blksize);
size += IMPSimprintsize(b);
+ } else {
+ MT_lock_unset(&b->theaplock);
}
*tot = size;
BBPunfix(*bid);
diff --git a/monetdb5/modules/kernel/batstr.c b/monetdb5/modules/kernel/batstr.c
--- a/monetdb5/modules/kernel/batstr.c
+++ b/monetdb5/modules/kernel/batstr.c
@@ -49,7 +49,6 @@ finalize_ouput(bat *res, BAT *bn, str ms
bn->tkey = BATcount(bn) <= 1;
bn->tsorted = BATcount(bn) <= 1;
bn->trevsorted = BATcount(bn) <= 1;
- bn->theap->dirty = true;
BBPkeepref(*res = bn->batCacheid);
} else if (bn)
BBPreclaim(bn);
diff --git a/monetdb5/modules/kernel/microbenchmark.c
b/monetdb5/modules/kernel/microbenchmark.c
--- a/monetdb5/modules/kernel/microbenchmark.c
+++ b/monetdb5/modules/kernel/microbenchmark.c
@@ -384,8 +384,7 @@ MBMmix(bat *bn, bat *batid)
*(int *) Tloc(b, idx) = val;
}
- BBPunfix(b->batCacheid);
- *bn = b->batCacheid;
+ BBPkeepref(*bn= b->batCacheid);
return MAL_SUCCEED;
}
diff --git a/monetdb5/modules/kernel/status.c b/monetdb5/modules/kernel/status.c
--- a/monetdb5/modules/kernel/status.c
+++ b/monetdb5/modules/kernel/status.c
@@ -226,25 +226,29 @@ SYSmemStatistics(bat *ret, bat *ret2)
throw(MAL, "status.memStatistics", SQLSTATE(HY013) MAL_MALLOC_FAIL);
}
-#define heap(X1,X2,X3,X4)
\
+#define heap(X1,X2,X3,X4,UNLOCK)
\
if (X1) {
\
sz = HEAPmemsize(X2);
\
if (sz > *minsize) {
\
sprintf(buf, X4"/%s", s);
\
if (BUNappend(bn, buf, false) != GDK_SUCCEED || \
- BUNappend(b, &sz, false) != GDK_SUCCEED)
\
+ BUNappend(b, &sz, false) != GDK_SUCCEED) {
\
+ UNLOCK;
\
goto bailout;
\
+ }
\
}
\
X3 += sz; tot += sz;
\
}
-#define heapvm(X1,X2,X3,X4)
\
+#define heapvm(X1,X2,X3,X4,UNLOCK)
\
if (X1) {
\
sz = HEAPvmsize(X2);
\
if (sz > *minsize) {
\
sprintf(buf, X4"/%s", s);
\
if (BUNappend(bn, buf, false) != GDK_SUCCEED || \
- BUNappend(b, &sz, false) != GDK_SUCCEED)
\
+ BUNappend(b, &sz, false) != GDK_SUCCEED) {
\
+ UNLOCK;
\
goto bailout;
\
+ }
\
}
\
X3 += sz; tot += sz;
\
}
@@ -288,15 +292,21 @@ SYSmem_usage(bat *ret, bat *ret2, const
}
tot += (lng) sz;
+ if (c)
+ MT_lock_set(&c->theaplock);
if (c == NULL || isVIEW(c)) {
+ if (c)
+ MT_lock_unset(&c->theaplock);
continue;
}
- heap(1,c->theap,tbuns,"tbuns");
+
+ heap(1,c->theap,tbuns,"tbuns", MT_lock_unset(&c->theaplock));
+ heap(c->tvheap,c->tvheap,tail,"tail",
MT_lock_unset(&c->theaplock));
+ MT_lock_unset(&c->theaplock);
MT_rwlock_rdlock(&c->thashlock);
- heap(c->thash && c->thash != (Hash *)
1,&c->thash->heaplink,thsh,"thshl");
- heap(c->thash && c->thash != (Hash *)
1,&c->thash->heapbckt,thsh,"thshb");
- MT_rwlock_rdunlock(&b->thashlock);
- heap(c->tvheap,c->tvheap,tail,"tail");
+ heap(c->thash && c->thash != (Hash *)
1,&c->thash->heaplink,thsh,"thshl",MT_rwlock_rdunlock(&c->thashlock));
+ heap(c->thash && c->thash != (Hash *)
1,&c->thash->heapbckt,thsh,"thshb",MT_rwlock_rdunlock(&c->thashlock));
+ MT_rwlock_rdunlock(&c->thashlock);
}
/* totals per category */
if (BUNappend(bn, "_tot/hbuns", false) != GDK_SUCCEED ||
@@ -390,15 +400,22 @@ SYSvm_usage(bat *ret, bat *ret2, const l
s = BBP_logical(i);
c = BBP_cache(i);
+
+ if (c)
+ MT_lock_set(&c->theaplock);
if (c == NULL || isVIEW(c)) {
+ if (c)
+ MT_lock_unset(&c->theaplock);
continue;
}
- heapvm(1,c->theap,tbuns,"tcuns");
+
+ heapvm(1,c->theap,tbuns,"tcuns",MT_lock_unset(&c->theaplock));
+
heapvm(c->tvheap,c->tvheap,tail,"tail",MT_lock_unset(&c->theaplock));
+ MT_lock_unset(&c->theaplock);
MT_rwlock_rdlock(&c->thashlock);
- heapvm(c->thash && c->thash != (Hash *)
1,&c->thash->heaplink,thsh,"thshl");
- heapvm(c->thash && c->thash != (Hash *)
1,&c->thash->heapbckt,thsh,"thshb");
+ heapvm(c->thash && c->thash != (Hash *)
1,&c->thash->heaplink,thsh,"thshl",MT_rwlock_rdunlock(&c->thashlock));
+ heapvm(c->thash && c->thash != (Hash *)
1,&c->thash->heapbckt,thsh,"thshb",MT_rwlock_rdunlock(&c->thashlock));
MT_rwlock_rdunlock(&c->thashlock);
- heapvm(c->tvheap,c->tvheap,tail,"tail");
}
/* totals per category */
if (BUNappend(bn, "_tot/hbuns", false) != GDK_SUCCEED ||
diff --git a/monetdb5/modules/mal/batExtensions.c
b/monetdb5/modules/mal/batExtensions.c
--- a/monetdb5/modules/mal/batExtensions.c
+++ b/monetdb5/modules/mal/batExtensions.c
@@ -75,10 +75,9 @@ CMDBATdup(Client cntxt, MalBlkPtr mb, Ma
bat input = *getArgReference_bat(stk, pci, 2);
(void)cntxt;
- if ((i = BATdescriptor(input)) == NULL)
+ if ((i = BBPquickdesc(input)) == NULL)
throw(MAL, "bat.new", INTERNAL_BAT_ACCESS);
b = COLnew(i->hseqbase, tt, BATcount(i), TRANSIENT);
- BBPunfix(i->batCacheid);
if (b == 0)
throw(MAL,"bat.new", SQLSTATE(HY013) MAL_MALLOC_FAIL);
*ret = b->batCacheid;
diff --git a/monetdb5/modules/mal/bbp.c b/monetdb5/modules/mal/bbp.c
--- a/monetdb5/modules/mal/bbp.c
+++ b/monetdb5/modules/mal/bbp.c
@@ -432,6 +432,7 @@ CMDbbp(bat *ID, bat *NS, bat *TT, bat *C
mode = "transient";
len = snprintf(buf, FILENAME_MAX, "%s",
BBP_physical(i));
if (len == -1 || len >= FILENAME_MAX) {
+ BBPunfix(bn->batCacheid);
msg = createException(MAL,
"catalog.bbp", SQLSTATE(HY013) "Could not bpp filename path is too large");
goto bailout;
}
diff --git a/monetdb5/modules/mal/groupby.c b/monetdb5/modules/mal/groupby.c
--- a/monetdb5/modules/mal/groupby.c
+++ b/monetdb5/modules/mal/groupby.c
@@ -183,10 +183,9 @@ GROUPmulticolumngroup(Client cntxt, MalB
if (msg == MAL_SUCCEED && aggr->last > 1)
do {
/* early break when there are as many groups as entries
*/
- b = BATdescriptor(*hist);
+ b = BBPquickdesc(*hist);
if (b) {
j = BATcount(b) == count;
- BBPunfix(*hist);
if (j)
break;
}
diff --git a/monetdb5/modules/mal/inspect.c b/monetdb5/modules/mal/inspect.c
--- a/monetdb5/modules/mal/inspect.c
+++ b/monetdb5/modules/mal/inspect.c
@@ -670,10 +670,9 @@ INSPECTtypeName(Client cntxt, MalBlkPtr
} else if (isaBatType(getArgType(mb,pci,1) ) ){
bat *bid= getArgReference_bat(stk,pci,1);
BAT *b;
- if ((b = BATdescriptor(*bid)) ) {
+ if ((b = BBPquickdesc(*bid)))
*hn = getTypeName(newBatType(b->ttype));
- BBPunfix(b->batCacheid);
- } else
+ else
*hn = getTypeName(getArgType(mb, pci, 1));
} else
*hn = getTypeName(getArgType(mb, pci, 1));
diff --git a/monetdb5/modules/mal/json_util.c b/monetdb5/modules/mal/json_util.c
--- a/monetdb5/modules/mal/json_util.c
+++ b/monetdb5/modules/mal/json_util.c
@@ -23,41 +23,24 @@ JSONresultSet(json *res, bat *uuid, bat
char *result;
size_t sz, len=0;
- if ((bu = BATdescriptor(*uuid)) == NULL)
+ if ((bu = BBPquickdesc(*uuid)) == NULL)
throw(MAL, "json.resultset", INTERNAL_BAT_ACCESS);
- if ((br = BATdescriptor(*rev)) == NULL) {
- BBPunfix(bu->batCacheid);
+ if ((br = BBPquickdesc(*rev)) == NULL)
throw(MAL, "json.resultset", INTERNAL_BAT_ACCESS);
- }
- if ((bj = BATdescriptor(*js)) == NULL) {
- BBPunfix(bu->batCacheid);
- BBPunfix(br->batCacheid);
+ if ((bj = BBPquickdesc(*js)) == NULL)
throw(MAL, "json.resultset", INTERNAL_BAT_ACCESS);
- }
- if ( !(BATcount(bu) == BATcount(br) && BATcount(br) == BATcount(bj)) ){
- BBPunfix(bu->batCacheid);
- BBPunfix(br->batCacheid);
- BBPunfix(bj->batCacheid);
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list