Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cache the collection schema, only read from vatstore once per crank #7333

Merged
merged 6 commits into from
Apr 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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