Skip to content

Commit

Permalink
Merge pull request #7333 from Agoric/6360-schema-cache
Browse files Browse the repository at this point in the history
cache the collection schema, only read from vatstore once per crank
  • Loading branch information
mergify[bot] authored Apr 11, 2023
2 parents d454b38 + 2faa0a3 commit 24de1b6
Show file tree
Hide file tree
Showing 13 changed files with 167 additions and 135 deletions.
12 changes: 4 additions & 8 deletions packages/SwingSet/test/virtualObjects/test-representatives.js
Original file line number Diff line number Diff line change
Expand Up @@ -452,21 +452,17 @@ test('virtual object gc', async t => {
[`${v}.vs.storeKindIDTable`]:
'{"scalarMapStore":2,"scalarWeakMapStore":3,"scalarSetStore":4,"scalarWeakSetStore":5,"scalarDurableMapStore":6,"scalarDurableWeakMapStore":7,"scalarDurableSetStore":8,"scalarDurableWeakSetStore":9}',
[`${v}.vs.vc.1.|entryCount`]: '0',
[`${v}.vs.vc.1.|label`]: 'baggage',
[`${v}.vs.vc.1.|nextOrdinal`]: '1',
[`${v}.vs.vc.1.|schemata`]: vstr([M.string()]),
[`${v}.vs.vc.1.|schemata`]: vstr({ label: 'baggage', keyShape: M.string() }),
[`${v}.vs.vc.2.|entryCount`]: '0',
[`${v}.vs.vc.2.|label`]: 'promiseRegistrations',
[`${v}.vs.vc.2.|nextOrdinal`]: '1',
[`${v}.vs.vc.2.|schemata`]: vstr([M.scalar()]),
[`${v}.vs.vc.2.|schemata`]: vstr({ label: 'promiseRegistrations', keyShape: M.scalar() }),
[`${v}.vs.vc.3.|entryCount`]: '0',
[`${v}.vs.vc.3.|label`]: 'promiseWatcherByKind',
[`${v}.vs.vc.3.|nextOrdinal`]: '1',
[`${v}.vs.vc.3.|schemata`]: vstr([M.scalar()]),
[`${v}.vs.vc.3.|schemata`]: vstr({ label: 'promiseWatcherByKind', keyShape: M.scalar() }),
[`${v}.vs.vc.4.|entryCount`]: '0',
[`${v}.vs.vc.4.|label`]: 'watchedPromises',
[`${v}.vs.vc.4.|nextOrdinal`]: '1',
[`${v}.vs.vc.4.|schemata`]: vstr([M.and(M.scalar(), M.string())]),
[`${v}.vs.vc.4.|schemata`]: vstr({ label: 'watchedPromises', keyShape: M.and(M.scalar(), M.string()) }),
[`${v}.vs.vom.es.o+v10/3`]: 'r',
[`${v}.vs.vom.o+v10/2`]: `{"label":${vstr('thing #2')}}`,
[`${v}.vs.vom.o+v10/3`]: `{"label":${vstr('thing #3')}}`,
Expand Down
3 changes: 3 additions & 0 deletions packages/swingset-liveslots/src/cache.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ export function makeCache(readBacking, writeBacking, deleteBacking) {
const dirtyKeys = new Set();
const cache = {
get: key => {
assert.typeof(key, 'string');
if (stash.has(key)) {
return stash.get(key);
} else if (dirtyKeys.has(key)) {
Expand All @@ -75,10 +76,12 @@ export function makeCache(readBacking, writeBacking, deleteBacking) {
return value;
},
set: (key, value) => {
assert.typeof(key, 'string');
stash.set(key, value);
dirtyKeys.add(key);
},
delete: key => {
assert.typeof(key, 'string');
stash.delete(key);
dirtyKeys.add(key);
},
Expand Down
Loading

0 comments on commit 24de1b6

Please sign in to comment.