Skip to content

Commit

Permalink
WIP: snapstore logging
Browse files Browse the repository at this point in the history
  • Loading branch information
dckc committed May 19, 2021
1 parent de77415 commit 18e7e44
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
5 changes: 5 additions & 0 deletions packages/SwingSet/src/controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ function unhandledRejectionHandler(e) {
* }} opts
*/
export function makeStartXSnap(bundles, { snapStore, env, spawn }) {
console.log('@@makeStartXSnap', { snapStore });
console.error('@@makeStartXSnap trace', Error());
/** @type { import('@agoric/xsnap/src/xsnap').XSnapOptions } */
const xsnapOpts = {
os: osType(),
Expand All @@ -68,12 +70,14 @@ export function makeStartXSnap(bundles, { snapStore, env, spawn }) {
*/
async function startXSnap(name, handleCommand, metered) {
if (supervisorHash && snapStore) {
console.log('@@startXSnap from', { supervisorHash });
return snapStore.load(supervisorHash, async snapshot => {
const xs = xsnap({ snapshot, name, handleCommand, ...xsnapOpts });
await xs.evaluate('null'); // ensure that spawn is done
return xs;
});
}
console.log('@@fresh xsnap', { snapstore: snapStore });
const meterOpts = metered ? {} : { meteringLimit: 0 };
const worker = xsnap({ handleCommand, name, ...meterOpts, ...xsnapOpts });

Expand All @@ -87,6 +91,7 @@ export function makeStartXSnap(bundles, { snapStore, env, spawn }) {
}
if (snapStore) {
supervisorHash = await snapStore.save(async fn => worker.snapshot(fn));
console.log('@@startXSnap saved to', { supervisorHash });
}
return worker;
}
Expand Down
2 changes: 2 additions & 0 deletions packages/xsnap/src/snapStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ export function makeSnapstore(
return withTempName(async snapFile => {
await saveRaw(snapFile);
const h = await fileHash(snapFile);
console.log('@@@save', { snapFile, h });
if (existsSync(`${h}.gz`)) return h;
await atomicWrite(`${h}.gz`, gztmp =>
filter(snapFile, createGzip(), gztmp),
Expand All @@ -118,6 +119,7 @@ export function makeSnapstore(
return withTempName(async raw => {
await filter(resolve(root, `${hash}.gz`), createGunzip(), raw);
const actual = await fileHash(raw);
console.log('@@@load', { raw, hash });
assert(actual === hash, d`actual hash ${actual} !== expected ${hash}`);
// be sure to await loadRaw before exiting withTempName
const result = await loadRaw(raw);
Expand Down

0 comments on commit 18e7e44

Please sign in to comment.