From 901cc267e52413504b5fb374f59a77e84eac04c4 Mon Sep 17 00:00:00 2001 From: Brian Warner Date: Tue, 4 Apr 2023 22:44:29 -0700 Subject: [PATCH] remove in-RAM list of all collections 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 --- .../src/collectionManager.js | 24 ------------------- 1 file changed, 24 deletions(-) diff --git a/packages/swingset-liveslots/src/collectionManager.js b/packages/swingset-liveslots/src/collectionManager.js index a4eab91bff71..30e5b76fa4bf 100644 --- a/packages/swingset-liveslots/src/collectionManager.js +++ b/packages/swingset-liveslots/src/collectionManager.js @@ -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 = { @@ -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}`; @@ -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, '|'))) { @@ -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]); @@ -712,7 +690,6 @@ export function makeCollectionManager( JSON.stringify(serialize(harden(schemata))), ); syscall.vatstoreSet(prefixc(collectionID, '|label'), label); - allCollectionObjIDs.add(vobjID); return [ vobjID, @@ -1023,7 +1000,6 @@ export function makeCollectionManager( return harden({ initializeStoreKindInfo, - deleteAllVirtualCollections, makeScalarBigMapStore, makeScalarBigWeakMapStore, makeScalarBigSetStore,