Skip to content

Commit

Permalink
remove in-RAM list of all collections
Browse files Browse the repository at this point in the history
This removes `deleteAllVirtualCollections`, and the in-RAM
`allCollectionObjIDs` Set of all collectionIDs which supported
it. Once upon a time, `stopVat` called `deleteAllVirtualCollections`
to delete the vatstore data for all non-durable virtual
collections. We removed responsibility for deleting virtual data from
the vat (and stopped calling `stopVat` altogether) in the interests of
reducing upgrade risk, and improving upgrade performance, despite the
fact that this will cause a DB storage leak during upgrade (we figure
we can find a way to fix that later, and disk is cheap).

Now that `deleteAllVirtualCollections` is gone, we don't need to spend
the RAM on each collection, which violated our high-cardinality design
rules anyways.

refs #5058
  • Loading branch information
warner committed Apr 10, 2023
1 parent c75147f commit 901cc26
Showing 1 changed file with 0 additions and 24 deletions.
24 changes: 0 additions & 24 deletions packages/swingset-liveslots/src/collectionManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,6 @@ export function makeCollectionManager(
unserialize,
assertAcceptableSyscallCapdataSize,
) {
// TODO(#5058): we hold a list of all collections (both virtual and
// durable) in RAM, so we can delete the virtual ones during
// stopVat(), and tolerate subsequent GC-triggered duplication
// deletion without crashing. This needs to move to the DB to avoid
// the RAM consumption of a large number of collections.
const allCollectionObjIDs = new Set();
const storeKindIDToName = new Map();

const storeKindInfo = {
Expand Down Expand Up @@ -656,9 +650,6 @@ export function makeCollectionManager(
}

function deleteCollection(vobjID) {
if (!allCollectionObjIDs.has(vobjID)) {
return false; // already deleted
}
const { id, subid } = parseVatSlot(vobjID);
const kindName = storeKindIDToName.get(`${id}`);
const collectionID = `${subid}`;
Expand All @@ -668,7 +659,6 @@ export function makeCollectionManager(
collectionID,
kindName,
);
allCollectionObjIDs.delete(vobjID);

const doMoreGC = collection.clearInternal(true);
for (const dbKey of enumerateKeysWithPrefix(syscall, prefixc(subid, '|'))) {
Expand All @@ -677,18 +667,6 @@ export function makeCollectionManager(
return doMoreGC;
}

function deleteAllVirtualCollections() {
const vobjIDs = Array.from(allCollectionObjIDs).sort();
for (const vobjID of vobjIDs) {
const { id } = parseVatSlot(vobjID);
const kindName = storeKindIDToName.get(`${id}`);
const { durable } = storeKindInfo[kindName];
if (!durable) {
deleteCollection(vobjID);
}
}
}

function makeCollection(label, kindName, isDurable, keyShape, valueShape) {
assert.typeof(label, 'string');
assert(storeKindInfo[kindName]);
Expand All @@ -712,7 +690,6 @@ export function makeCollectionManager(
JSON.stringify(serialize(harden(schemata))),
);
syscall.vatstoreSet(prefixc(collectionID, '|label'), label);
allCollectionObjIDs.add(vobjID);

return [
vobjID,
Expand Down Expand Up @@ -1023,7 +1000,6 @@ export function makeCollectionManager(

return harden({
initializeStoreKindInfo,
deleteAllVirtualCollections,
makeScalarBigMapStore,
makeScalarBigWeakMapStore,
makeScalarBigSetStore,
Expand Down

0 comments on commit 901cc26

Please sign in to comment.