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

Summarizer telemetry and cleanup [0.10] #327

Merged
merged 11 commits into from
Oct 14, 2019
3 changes: 3 additions & 0 deletions packages/loader/container-definitions/src/deltas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,9 @@ export interface IDeltaManager<T, U> extends EventEmitter, IDeltaSender, IDispos
// The last sequence number processed by the delta manager
referenceSequenceNumber: number;

// The initial sequence number set when attaching the op handler
initialSequenceNumber: number;

// Type of client
clientType: string;

Expand Down
9 changes: 8 additions & 1 deletion packages/loader/container-loader/src/deltaManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,9 @@ export class DeltaManager extends EventEmitter implements IDeltaManager<ISequenc
private lastQueuedSequenceNumber: number = 0;
private baseSequenceNumber: number = 0;

// the sequence number we initially loaded from
private initSequenceNumber: number = 0;

private readonly _inboundPending: DeltaQueue<ISequencedDocumentMessage>;
private readonly _inbound: DeltaQueue<ISequencedDocumentMessage>;
private readonly _inboundSignal: DeltaQueue<ISignalMessage>;
Expand Down Expand Up @@ -132,6 +135,10 @@ export class DeltaManager extends EventEmitter implements IDeltaManager<ISequenc
return this._inboundSignal;
}

public get initialSequenceNumber(): number {
return this.initSequenceNumber;
}

public get referenceSequenceNumber(): number {
return this.baseSequenceNumber;
}
Expand Down Expand Up @@ -277,7 +284,7 @@ export class DeltaManager extends EventEmitter implements IDeltaManager<ISequenc
resume: boolean) {
debug("Attached op handler", sequenceNumber);

this.baseSequenceNumber = sequenceNumber;
this.baseSequenceNumber = this.initSequenceNumber = sequenceNumber;
arinwt marked this conversation as resolved.
Show resolved Hide resolved
this.minSequenceNumber = minSequenceNumber;
this.lastQueuedSequenceNumber = sequenceNumber;

Expand Down
4 changes: 4 additions & 0 deletions packages/loader/container-loader/src/deltaManagerProxy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,10 @@ export class DeltaManagerProxy
return this.deltaManager.referenceSequenceNumber;
}

public get initialSequenceNumber(): number {
return this.deltaManager.initialSequenceNumber;
}

public get clientType(): string {
return this.deltaManager.clientType;
}
Expand Down
29 changes: 23 additions & 6 deletions packages/runtime/container-runtime/src/containerRuntime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import {
Deferred,
flatten,
isSystemType,
PerformanceEvent,
raiseConnectedEvent,
readAndParse,
} from "@microsoft/fluid-core-utils";
Expand Down Expand Up @@ -468,6 +469,12 @@ export class ContainerRuntime extends EventEmitter implements IHostRuntime, IRun
return this.summaryManager.summarizer;
}

private get summaryConfiguration() {
return this.context.serviceConfiguration
? { ...DefaultSummaryConfiguration, ...this.context.serviceConfiguration.summary }
: DefaultSummaryConfiguration;
}

// Components tracked by the Domain
private closed = false;
private readonly pendingAttach = new Map<string, IAttachMessage>();
Expand Down Expand Up @@ -555,18 +562,14 @@ export class ContainerRuntime extends EventEmitter implements IHostRuntime, IRun
this.context.on("refreshBaseSummary",
(snapshot: ISnapshotTree) => this.refreshBaseSummary(snapshot));

const summaryConfiguration = context.serviceConfiguration
? { ...DefaultSummaryConfiguration, ...context.serviceConfiguration.summary }
: DefaultSummaryConfiguration;

// We always create the summarizer in the case that we are asked to generate summaries. But this may
// want to be on demand instead.
// Don't use optimizations when generating summaries with a document loaded using snapshots.
// This will ensure we correctly convert old documents.
this.summarizer = new Summarizer(
"/_summarizer",
this,
summaryConfiguration,
() => this.summaryConfiguration,
() => this.generateSummary(!this.loadedFromSummary),
(snapshot) => this.context.refreshBaseSummary(snapshot));

Expand Down Expand Up @@ -1090,6 +1093,11 @@ export class ContainerRuntime extends EventEmitter implements IHostRuntime, IRun
return;
}

const generateSummaryEvent = PerformanceEvent.start(this.logger, {
eventName: "GenerateSummary",
fullTree,
});

try {
await this.scheduleManager.pause();
const sequenceNumber = this.deltaManager.referenceSequenceNumber;
Expand All @@ -1107,9 +1115,11 @@ export class ContainerRuntime extends EventEmitter implements IHostRuntime, IRun
// after loading from the beginning of the snapshot
const versions = await this.context.storage.getVersions(this.id, 1);
const parents = versions.map((version) => version.id);
generateSummaryEvent.reportProgress({}, "loadedVersions");

const treeWithStats = await this.summarize(fullTree);
ret.summaryStats = treeWithStats.summaryStats;
generateSummaryEvent.reportProgress({}, "generatedTree");

if (!this.connected) {
return ret;
Expand All @@ -1121,6 +1131,7 @@ export class ContainerRuntime extends EventEmitter implements IHostRuntime, IRun
message,
parents,
};
generateSummaryEvent.reportProgress({}, "uploadedTree");

if (!this.connected) {
return ret;
Expand All @@ -1129,9 +1140,15 @@ export class ContainerRuntime extends EventEmitter implements IHostRuntime, IRun
this.submit(MessageType.Summarize, summary);
ret.submitted = true;

generateSummaryEvent.end({
sequenceNumber,
submitted: ret.submitted,
handle: handle.handle,
...ret.summaryStats,
});
return ret;
} catch (ex) {
this.logger.logException({ eventName: "Summarizer:GenerateSummaryExceptionError" }, ex);
generateSummaryEvent.cancel({}, ex);
throw ex;
} finally {
// Restart the delta manager
Expand Down
Loading