Changeset: bbc00de423ec for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/bbc00de423ec
Modified Files:
gdk/gdk_bbp.c
gdk/gdk_logger.c
Branch: Jan2022
Log Message:
Merge with Jul2021 branch.
diffs (148 lines):
diff --git a/gdk/gdk_bbp.c b/gdk/gdk_bbp.c
--- a/gdk/gdk_bbp.c
+++ b/gdk/gdk_bbp.c
@@ -4008,60 +4008,54 @@ BBPsync(int cnt, bat *restrict subcommit
&obbpf, &nbbpf);
}
- if (ret == GDK_SUCCEED) {
- int idx = 0;
-
- while (++idx < cnt) {
- bat i = subcommit ? subcommit[idx] : idx;
- /* BBP_desc(i) may be NULL */
- BUN size = sizes ? sizes[idx] : BUN_NONE;
- BATiter bi;
-
- if (BBP_status(i) & BBPPERSISTENT) {
- BAT *b = dirty_bat(&i, subcommit != NULL);
- if (i <= 0) {
- break;
- }
- bi = bat_iterator(BBP_desc(i));
- assert(sizes == NULL || size <= bi.count);
- assert(sizes == NULL || bi.width == 0 ||
(bi.type == TYPE_msk ? ((size + 31) / 32) * 4 : size << bi.shift) <= bi.hfree);
- if (size > bi.count) /* includes sizes==NULL */
- size = bi.count;
- bi.b->batInserted = size;
- if (b && size != 0) {
- /* wait for BBPSAVING so that we
- * can set it, wait for
- * BBPUNLOADING before
- * attempting to save */
- for (;;) {
- if (lock)
-
MT_lock_set(&GDKswapLock(i));
- if (!(BBP_status(i) &
(BBPSAVING|BBPUNLOADING)))
- break;
- if (lock)
-
MT_lock_unset(&GDKswapLock(i));
- BBPspin(i, __func__,
BBPSAVING|BBPUNLOADING);
- }
- BBP_status_on(i, BBPSAVING);
+ for (int idx = 1; ret == GDK_SUCCEED && idx < cnt; idx++) {
+ bat i = subcommit ? subcommit[idx] : idx;
+ /* BBP_desc(i) may be NULL */
+ BUN size = sizes ? sizes[idx] : BUN_NONE;
+ BATiter bi;
+
+ if (BBP_status(i) & BBPPERSISTENT) {
+ BAT *b = dirty_bat(&i, subcommit != NULL);
+ if (i <= 0) {
+ ret = GDK_FAIL;
+ break;
+ }
+ bi = bat_iterator(BBP_desc(i));
+ assert(sizes == NULL || size <= bi.count);
+ assert(sizes == NULL || bi.width == 0 || (bi.type ==
TYPE_msk ? ((size + 31) / 32) * 4 : size << bi.shift) <= bi.hfree);
+ if (size > bi.count) /* includes sizes==NULL */
+ size = bi.count;
+ bi.b->batInserted = size;
+ if (b && size != 0) {
+ /* wait for BBPSAVING so that we
+ * can set it, wait for
+ * BBPUNLOADING before
+ * attempting to save */
+ for (;;) {
+ if (lock)
+ MT_lock_set(&GDKswapLock(i));
+ if (!(BBP_status(i) &
(BBPSAVING|BBPUNLOADING)))
+ break;
if (lock)
MT_lock_unset(&GDKswapLock(i));
- ret = BATsave_iter(b, &bi, size);
- BBP_status_off(i, BBPSAVING);
+ BBPspin(i, __func__,
BBPSAVING|BBPUNLOADING);
}
- } else {
- bi = bat_iterator(NULL);
- }
- if (ret == GDK_SUCCEED) {
- n = BBPdir_step(i, size, n, buf, sizeof(buf),
&obbpf, nbbpf, &bi);
+ BBP_status_on(i, BBPSAVING);
+ if (lock)
+ MT_lock_unset(&GDKswapLock(i));
+ ret = BATsave_iter(b, &bi, size);
+ BBP_status_off(i, BBPSAVING);
}
- bat_iterator_end(&bi);
- if (n == -2)
- break;
- /* we once again have a saved heap */
+ } else {
+ bi = bat_iterator(NULL);
}
- if (idx < cnt) {
- ret = GDK_FAIL;
+ if (ret == GDK_SUCCEED) {
+ n = BBPdir_step(i, size, n, buf, sizeof(buf), &obbpf,
nbbpf, &bi);
+ if (n < -1)
+ ret = GDK_FAIL;
}
+ bat_iterator_end(&bi);
+ /* we once again have a saved heap */
}
TRC_DEBUG(PERF, "write time %d\n", (t0 = GDKms()) - t1);
diff --git a/gdk/gdk_logger.c b/gdk/gdk_logger.c
--- a/gdk/gdk_logger.c
+++ b/gdk/gdk_logger.c
@@ -894,9 +894,9 @@ la_apply(logger *lg, logaction *c, int t
static void
la_destroy(logaction *c)
{
- if (c->b && (c->type == LOG_UPDATE || c->type == LOG_UPDATE_BULK))
+ if ((c->type == LOG_UPDATE || c->type == LOG_UPDATE_BULK) && c->b)
logbat_destroy(c->b);
- if (c->uid && c->type == LOG_UPDATE)
+ if (c->type == LOG_UPDATE && c->uid)
logbat_destroy(c->uid);
}
@@ -1486,7 +1486,7 @@ subcommit_list_add(int next, bat *n, BUN
}
static int
-cleanup_and_swap(logger *lg, int *r, const log_bid *bids, lng *lids, lng
*cnts, BAT *catalog_bid, BAT *catalog_id, BAT *dcatalog, int cleanup)
+cleanup_and_swap(logger *lg, int *r, const log_bid *bids, lng *lids, lng
*cnts, BAT *catalog_bid, BAT *catalog_id, BAT *dcatalog, BUN cleanup)
{
BAT *nbids, *noids, *ncnts, *nlids, *ndels;
BUN p, q;
@@ -1611,7 +1611,7 @@ bm_subcommit(logger *lg)
gdk_return res;
const log_bid *bids;
lng *cnts = NULL, *lids = NULL;
- int cleanup = 0;
+ BUN cleanup = 0;
lng t0 = 0;
if (n == NULL || r == NULL || sizes == NULL) {
@@ -1648,6 +1648,8 @@ bm_subcommit(logger *lg)
sizes[i] = BATcount(dcatalog);
n[i++] = dcatalog->batCacheid;
+ if (cleanup < (lg->cnt/2))
+ cleanup = 0;
if (cleanup && (rcnt=cleanup_and_swap(lg, r, bids, lids, cnts,
catalog_bid, catalog_id, dcatalog, cleanup)) < 0) {
GDKfree(n);
GDKfree(r);
_______________________________________________
checkin-list mailing list -- [email protected]
To unsubscribe send an email to [email protected]