Changeset: 5fba2fde0810 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/5fba2fde0810
Modified Files:
gdk/gdk_bbp.c
gdk/gdk_bbp.h
Branch: Jul2021
Log Message:
Introduce a BBPHOT status bit to indicate active use of a bat.
When the bit is cleared before a physical decref to 0, and no further
physical increfs happen, the bat will be unloaded (swapped out) when
the decref happens.
diffs (55 lines):
diff --git a/gdk/gdk_bbp.c b/gdk/gdk_bbp.c
--- a/gdk/gdk_bbp.c
+++ b/gdk/gdk_bbp.c
@@ -1837,7 +1837,7 @@ BBPinsert(BAT *bn)
bn->batCacheid = i;
bn->creator_tid = MT_getpid();
- BBP_status_set(i, BBPDELETING);
+ BBP_status_set(i, BBPDELETING|BBPHOT);
BBP_cache(i) = NULL;
BBP_desc(i) = NULL;
BBP_refs(i) = 1; /* new bats have 1 pin */
@@ -2183,15 +2183,17 @@ incref(bat i, bool logical, bool lock)
assert(tp >= 0);
tvp = b->tvheap == 0 || b->tvheap->parentid == i ? 0 :
b->tvheap->parentid;
refs = ++BBP_refs(i);
+ unsigned flag = BBPHOT;
if (refs == 1 && (tp || tvp)) {
/* If this is a view, we must load the parent
* BATs, but we must do that outside of the
* lock. Set the BBPLOADING flag so that
* other threads will wait until we're
* done. */
- BBP_status_on(i, BBPLOADING);
+ flag |= BBPLOADING;
load = true;
}
+ BBP_status_on(i, flag);
}
if (lock)
MT_lock_unset(&GDKswapLock(i));
@@ -2313,7 +2315,10 @@ decref(bat i, bool logical, bool release
* if they have been made cold or are not dirty */
if (BBP_refs(i) > 0 ||
(BBP_lrefs(i) > 0 &&
- (b == NULL || BATdirty(b) || !(BBP_status(i) & BBPPERSISTENT) ||
GDKinmemory(b->theap->farmid)))) {
+ (b == NULL ||
+ (BATdirty(b) && (BBP_status(i) & BBPHOT)) ||
+ (BBP_status(i) & (BBPPERSISTENT | BBPHOT)) == BBPHOT ||
+ GDKinmemory(b->theap->farmid)))) {
/* bat cannot be swapped out */
} else if (b ? b->batSharecnt == 0 : (BBP_status(i) & BBPTMP)) {
/* bat will be unloaded now. set the UNLOADING bit
diff --git a/gdk/gdk_bbp.h b/gdk/gdk_bbp.h
--- a/gdk/gdk_bbp.h
+++ b/gdk/gdk_bbp.h
@@ -51,6 +51,8 @@
#define BBPUNSTABLE (BBPUNLOADING|BBPDELETING) /* set while we are
unloading */
#define BBPWAITING (BBPUNLOADING|BBPLOADING|BBPSAVING|BBPDELETING)
+#define BBPHOT 4096 /* bat is "hot", i.e. is still in active use */
+
#define BBPTRIM_ALL (((size_t)1) << (sizeof(size_t)*8 - 2)) /* very large
positive size_t */
gdk_export bat getBBPsize(void); /* current occupied size of BBP array */
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list