-
Notifications
You must be signed in to change notification settings - Fork 214
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
Add a reapAllVats
method to the controller
#8634
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { Far, E } from '@endo/far'; | ||
|
||
export function buildRootObject() { | ||
let vatAdmin; | ||
let bcap; | ||
const roots = []; | ||
|
||
return Far('root', { | ||
async bootstrap(vats, devices) { | ||
vatAdmin = await E(vats.vatAdmin).createVatAdminService(devices.vatAdmin); | ||
bcap = await E(vatAdmin).getNamedBundleCap('dumbo'); | ||
console.log('end of bootstrap, vatAdmin', vatAdmin); | ||
}, | ||
|
||
async createDynamicVats() { | ||
for (let i = 0; i < 3; i += 1) { | ||
const res = await E(vatAdmin).createVat(bcap); | ||
roots.push(res.root); | ||
} | ||
return roots; | ||
}, | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
// eslint-disable-next-line import/order | ||
import { test } from '../../tools/prepare-test-env-ava.js'; | ||
|
||
import { initSwingStore } from '@agoric/swing-store'; | ||
import { kunser } from '@agoric/kmarshal'; | ||
|
||
import { initializeSwingset, makeSwingsetController } from '../../src/index.js'; | ||
|
||
function bfile(name) { | ||
return new URL(name, import.meta.url).pathname; | ||
} | ||
|
||
test('reap all vats', async t => { | ||
/** @type {SwingSetConfig} */ | ||
const config = { | ||
defaultManagerType: 'local', | ||
defaultReapInterval: 4, | ||
bootstrap: 'bootstrap', | ||
vats: { | ||
bootstrap: { sourceSpec: bfile('bootstrap-reap-all.js') }, | ||
staticDumbo1: { bundleName: 'dumbo' }, | ||
staticDumbo2: { bundleName: 'dumbo' }, | ||
staticDumbo3: { bundleName: 'dumbo' }, | ||
}, | ||
bundles: { | ||
dumbo: { sourceSpec: bfile('vat-dumbo.js') }, | ||
}, | ||
}; | ||
|
||
const kernelStorage = initSwingStore().kernelStorage; | ||
await initializeSwingset(config, [], kernelStorage); | ||
const c = await makeSwingsetController(kernelStorage); | ||
t.teardown(c.shutdown); | ||
c.pinVatRoot('bootstrap'); | ||
c.pinVatRoot('staticDumbo1'); | ||
c.pinVatRoot('staticDumbo2'); | ||
c.pinVatRoot('staticDumbo3'); | ||
await c.run(); | ||
|
||
const kpid = c.queueToVatRoot('bootstrap', 'createDynamicVats'); | ||
await c.run(); | ||
|
||
const dynamicRoots = kunser(c.kpResolution(kpid)); | ||
for (let i = 0; i < 3; i += 1) { | ||
for (let j = 0; j < i + 1; j += 1) { | ||
c.queueToVatRoot(`staticDumbo${i + 1}`, 'doSomething', [ | ||
`staticDumbo${i + 1} #${j + 1}`, | ||
]); | ||
} | ||
} | ||
for (let i = 0; i < 3; i += 1) { | ||
for (let j = 0; j < i + 1; j += 1) { | ||
c.queueToVatObject(dynamicRoots[i], 'doSomething', [ | ||
`dynamicDumbo${i + 1} #${j + 1}`, | ||
]); | ||
} | ||
} | ||
// Note: no call to c.run() here, so all the above messages are still enqueued | ||
|
||
const dumpBefore = c.dump(); | ||
t.is(dumpBefore.acceptanceQueue.length, 12); | ||
t.is(dumpBefore.reapQueue.length, 0); | ||
t.is(dumpBefore.runQueue.length, 0); | ||
|
||
c.reapAllVats(); | ||
const dumpPreReap = c.dump(); | ||
t.is(dumpPreReap.acceptanceQueue.length, 12); | ||
t.is(dumpPreReap.reapQueue.length, 11); | ||
t.is(dumpBefore.runQueue.length, 0); | ||
// prettier-ignore | ||
const reapQueueReference = | ||
new Set(['v1', 'v3', 'v6', 'v7', 'v8', 'v5', 'v2', 'v4', 'v9', 'v10', 'v11']) | ||
const reapQueueActual = new Set(dumpPreReap.reapQueue); | ||
t.deepEqual(reapQueueActual, reapQueueReference); | ||
|
||
await c.run(); | ||
const dumpPostReap = c.dump(); | ||
t.is(dumpPostReap.acceptanceQueue.length, 0); | ||
FUDCo marked this conversation as resolved.
Show resolved
Hide resolved
|
||
t.is(dumpPostReap.reapQueue.length, 0); | ||
t.is(dumpBefore.runQueue.length, 0); | ||
|
||
t.pass(); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { Far } from '@endo/far'; | ||
|
||
export function buildRootObject() { | ||
return Far('root', { | ||
doSomething(msg) { | ||
console.log(`doSomething: ${msg}`); | ||
}, | ||
}); | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, neat, it didn't occur to me to use
reapQueue
for measuring this.. very clever.Let's see, the kernel servicing code:
services the
acceptanceQueue
first (transferring items to the run-queue), then takes any GC action, thenreapQueue
, then finallyrunQueue
. So when we use this feature for GC remediation, it's important to drain acontroller.run()
first (leaving all queues empty), then submit thec.reapAllVats()
, then drain a secondcontroller.run()
.(if we submitted the
reapAllVats()
while there were still things in the acceptance or run queues, the reaps would happen first, then the real deliveries, which would leave GC stuff from the real deliveries still hanging out for an unknown period of time before the "organic" BOYDs finally happened)