Skip to content

Instantly share code, notes, and snippets.

@jasonLaster
Created April 5, 2023 21:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jasonLaster/021d648d3936c66e7cec65458e92b8af to your computer and use it in GitHub Desktop.
Save jasonLaster/021d648d3936c66e7cec65458e92b8af to your computer and use it in GitHub Desktop.
diff --git a/src/control/channel.ts b/src/control/channel.ts
index d4468114b..7d0895044 100644
--- a/src/control/channel.ts
+++ b/src/control/channel.ts
@@ -198,6 +198,14 @@ const controllerHandlers: ControllerServerHandlers = {
runRoutines();
}
+ logger.info("ProcessingFinished",{
+ routineDuration: 0,
+ diffSnapshotDuration: 0,
+ success: true,
+ }, [
+ sendToHoneycomb: true
+ ])
+
// All controllers start off growing the process tree. The range of
// regions they will grow is determined from the controller spec.
const { growProcessTree } = await import("./linker/tree");
diff --git a/src/control/linker/diffedSnapshotSapling.ts b/src/control/linker/diffedSnapshotSapling.ts
index 455146303..59ccfced6 100644
--- a/src/control/linker/diffedSnapshotSapling.ts
+++ b/src/control/linker/diffedSnapshotSapling.ts
@@ -14,61 +14,63 @@ import { getSnapshotFilePath } from "./snapshots";
export async function produceDiffedSnapshots() {
if (
- Channel.getExperimentalSettings().enableIncrementalSnapshots &&
- (await LinkerProcess.hasSupportFor(LinkerCompatibility.IncrementalSnapshots))
+ !Channel.getExperimentalSettings().enableIncrementalSnapshots ||
+ !(await LinkerProcess.hasSupportFor(LinkerCompatibility.IncrementalSnapshots))
) {
- const cx = emptyContext("DiffedSnapshotSapling");
- try {
- cx.logger.debug("DiffedSnapshotTesting", { phase: "Start" });
- const child = newRootChild(cx.logger);
- let preparedSnapshot: PreparedSnapshotDiff | undefined;
- for await (const region of getRegionIterator()) {
- const endOfRegion = await getRegionAsync(region.endpoint.checkpoint, cx);
- child.ensureRecordingData(endOfRegion.recordingLength);
- if (!preparedSnapshot) {
- const createSnapshotResult = await child.createSnapshot(
- cx,
- /* prepareAfter */ true
- );
- assert(createSnapshotResult, "snapshot creation failed");
- preparedSnapshot = createSnapshotResult.prepareAfter;
- assert(preparedSnapshot, "missing prepared snapshot");
- const stream = fs.createReadStream(createSnapshotResult.localFile);
- await Channel.uploadRecordingAsset(
- await getSnapshotFilePath(child.startPoint.checkpoint),
- RecordingAssetType.SNAPSHOT,
- {},
- stream,
- cx
- );
- }
- await child.runToPoint(region.endpoint, cx);
- const createSnapshotDiffResult = await child.createSnapshotDiff(
- preparedSnapshot,
- // FIXME we should only set this when there is another region to iterate.
- // Preparing a snapshot diff but not consuming it will use up significant
- // system resources (i.e. shared memory) until the controller shuts down.
- /* prepareAfter */ true,
- cx
+ return;
+ }
+
+ const cx = emptyContext("DiffedSnapshotSapling");
+ try {
+ cx.logger.debug("DiffedSnapshotTesting", { phase: "Start" });
+ const child = newRootChild(cx.logger);
+ let preparedSnapshot: PreparedSnapshotDiff | undefined;
+ for await (const region of getRegionIterator()) {
+ const endOfRegion = await getRegionAsync(region.endpoint.checkpoint, cx);
+ child.ensureRecordingData(endOfRegion.recordingLength);
+ if (!preparedSnapshot) {
+ const createSnapshotResult = await child.createSnapshot(
+ cx,
+ /* prepareAfter */ true
);
- assert(createSnapshotDiffResult, "snapshot diff creation failed");
- preparedSnapshot = createSnapshotDiffResult.prepareAfter;
+ assert(createSnapshotResult, "snapshot creation failed");
+ preparedSnapshot = createSnapshotResult.prepareAfter;
assert(preparedSnapshot, "missing prepared snapshot");
- const snapshotDiff = await createReadStream(createSnapshotDiffResult.fileName);
- assert(snapshotDiff, "snapshot diff not found");
- const recordingId = await Channel.getRecordingId();
- const s3Filename = `${snapshotsDirectory}/${recordingId}/${recordingId}-${createSnapshotDiffResult.startCheckpoint}-${createSnapshotDiffResult.endCheckpoint}`;
+ const stream = fs.createReadStream(createSnapshotResult.localFile);
await Channel.uploadRecordingAsset(
- s3Filename,
- RecordingAssetType.SNAPSHOT_DIFF,
+ await getSnapshotFilePath(child.startPoint.checkpoint),
+ RecordingAssetType.SNAPSHOT,
{},
- snapshotDiff,
+ stream,
cx
);
}
- cx.logger.debug("DiffedSnapshotTesting", { phase: "Done" });
- } catch (e) {
- cx.logger.exception("DiffedSnapshotTesting", e);
+ await child.runToPoint(region.endpoint, cx);
+ const createSnapshotDiffResult = await child.createSnapshotDiff(
+ preparedSnapshot,
+ // FIXME we should only set this when there is another region to iterate.
+ // Preparing a snapshot diff but not consuming it will use up significant
+ // system resources (i.e. shared memory) until the controller shuts down.
+ /* prepareAfter */ true,
+ cx
+ );
+ assert(createSnapshotDiffResult, "snapshot diff creation failed");
+ preparedSnapshot = createSnapshotDiffResult.prepareAfter;
+ assert(preparedSnapshot, "missing prepared snapshot");
+ const snapshotDiff = await createReadStream(createSnapshotDiffResult.fileName);
+ assert(snapshotDiff, "snapshot diff not found");
+ const recordingId = await Channel.getRecordingId();
+ const s3Filename = `${snapshotsDirectory}/${recordingId}/${recordingId}-${createSnapshotDiffResult.startCheckpoint}-${createSnapshotDiffResult.endCheckpoint}`;
+ await Channel.uploadRecordingAsset(
+ s3Filename,
+ RecordingAssetType.SNAPSHOT_DIFF,
+ {},
+ snapshotDiff,
+ cx
+ );
}
+ cx.logger.debug("DiffedSnapshotTesting", { phase: "Done" });
+ } catch (e) {
+ cx.logger.exception("DiffedSnapshotTesting", e);
}
}
diff --git a/src/session/report.ts b/src/session/report.ts
index c1c2327b6..7ffa634c4 100644
--- a/src/session/report.ts
+++ b/src/session/report.ts
@@ -417,6 +417,7 @@ export class SessionReportManager {
return {
hasCachedData: this.hasCachedData,
+ hasIncrementalSnapshots: false,
duration: Date.now() - this.createTime,
fatalError,
fatalErrorCode,
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment