Changeset: 1196dd483f75 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/1196dd483f75
Modified Files:
gdk/gdk_bbp.c
Branch: Dec2023
Log Message:
Unload dirty cold bats that have persistent role but haven't yet been persisted.
These bats are likely registered in a part of the WAL that hasn't yet
been flushed, but they take up memory.
Also give other threads a chance of getting the TM lock by going to a
very short sleep every once in a while.
diffs (48 lines):
diff --git a/gdk/gdk_bbp.c b/gdk/gdk_bbp.c
--- a/gdk/gdk_bbp.c
+++ b/gdk/gdk_bbp.c
@@ -1717,10 +1717,12 @@ static bool
BBPtrim(bool aggressive, bat nbat)
{
int n = 0;
+ int waitctr = 0;
bool changed = false;
unsigned flag = BBPUNLOADING | BBPSYNCING | BBPSAVING;
if (!aggressive)
flag |= BBPHOT;
+ lng t0 = GDKusec();
for (bat bid = 1; bid < nbat && !GDKexiting(); bid++) {
/* don't do this during a (sub)commit */
BBPtmlock();
@@ -1734,11 +1736,11 @@ BBPtrim(bool aggressive, bat nbat)
MT_lock_set(&b->theaplock);
if (!BATshared(b) &&
!isVIEW(b) &&
- (!BATdirty(b) || (aggressive && b->theap->storage
== STORE_MMAP && (b->tvheap == NULL || b->tvheap->storage == STORE_MMAP))) /*&&
- (BBP_status(bid) & BBPPERSISTENT ||
- (b->batRole == PERSISTENT && BBP_lrefs(bid) == 1))
*/) {
+ (!BATdirty(b) || (aggressive && b->theap->storage
== STORE_MMAP && (b->tvheap == NULL || b->tvheap->storage == STORE_MMAP))) &&
+ (b->batRole == PERSISTENT && BBP_lrefs(bid) <= 2)) {
BBP_status_on(bid, BBPUNLOADING);
swap = true;
+ waitctr += BATdirty(b) ? 9 : 1;
}
MT_lock_unset(&b->theaplock);
}
@@ -1751,8 +1753,14 @@ BBPtrim(bool aggressive, bat nbat)
changed = true;
}
BBPtmunlock();
- }
- TRC_DEBUG(BAT_, "unloaded %d bats%s\n", n, aggressive ? " (also hot)" :
"");
+ /* every once in a while, give others a chance */
+ if (++waitctr >= 1000) {
+ waitctr = 0;
+ MT_sleep_ms(2);
+ }
+ }
+ if (n > 0)
+ TRC_INFO(BAT_, "unloaded %d bats in "LLFMT" usec%s\n", n,
GDKusec() - t0, aggressive ? " (also hot)" : "");
return changed;
}
_______________________________________________
checkin-list mailing list -- [email protected]
To unsubscribe send an email to [email protected]