Skip to content

Commit

Permalink
more updates
Browse files Browse the repository at this point in the history
  • Loading branch information
warner committed Aug 10, 2024
1 parent ffe2bec commit 164ed8b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
13 changes: 4 additions & 9 deletions packages/SwingSet/src/kernel/state/vatKeeper.js
Original file line number Diff line number Diff line change
Expand Up @@ -687,14 +687,11 @@ export function makeVatKeeper(
*/
function deleteSnapshots(budget = undefined) {
// Each budget=1 allows us to delete one snapshot entry.
let cleanups = 0;
if (!snapStore) {
return { done: true, cleanups };
return { done: true, cleanups: 0 };
}
// initially uses 2+2*budget DB statements, then just 1 when done
const dc = snapStore.deleteVatSnapshots(vatID, budget);
cleanups = dc.cleanups;
return { done: dc.done, cleanups };
return snapStore.deleteVatSnapshots(vatID, budget);
}

/**
Expand All @@ -713,11 +710,9 @@ export function makeVatKeeper(
// have historical transcript items, some will not. Using budget=5
// and snapshotInterval=200 means we delete 5 span records and
// maybe 1000 span items.
let cleanups = 0;

// initially uses 2+3*budget DB statements, then just 1 when done
const dc = transcriptStore.deleteVatTranscripts(vatID, budget);
cleanups = dc.cleanups;
return { done: dc.done, cleanups };
return transcriptStore.deleteVatTranscripts(vatID, budget);
}

function beginNewIncarnation() {
Expand Down
13 changes: 9 additions & 4 deletions packages/SwingSet/src/lib/runPolicies.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,16 +53,21 @@ export function crankCounter(
return policy;
}

export function computronCounter(limit) {
export function computronCounter(limit, options = {}) {
assert.typeof(limit, 'bigint');
const {
cleanupBudget = 100,
vatCreatedComputrons = 100_000n, // pretend that's the cost
crankFailedComputrons = 1_000_000n,
} = options;
let total = 0n;
/** @type { RunPolicy } */
const policy = harden({
allowCleanup() {
return { budget: 100 }; // limited budget
return { budget: cleanupBudget }; // limited budget
},
vatCreated() {
total += 100000n; // pretend vat creation takes 100k computrons
total += vatCreatedComputrons;
return total < limit;
},
crankComplete(details = {}) {
Expand All @@ -74,7 +79,7 @@ export function computronCounter(limit) {
return total < limit;
},
crankFailed() {
total += 1000000n; // who knows, 1M is as good as anything
total += crankFailedComputrons;
return total < limit;
},
emptyCrank() {
Expand Down

0 comments on commit 164ed8b

Please sign in to comment.