Skip to content

Commit

Permalink
notebook output performance (#209282)
Browse files Browse the repository at this point in the history
* record perf data for notebook outputs

* debounce event per cell

* send size info, emit directly from perf message listener

* fix classification details

* better names
  • Loading branch information
amunger authored Apr 1, 2024
1 parent 2c3efed commit 8f218ce
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -909,6 +909,9 @@ export class BackLayerWebView<T extends ICommonCellInfo> extends Themable {
}
case 'notebookPerformanceMessage': {
this.notebookEditor.updatePerformanceMetadata(data.cellId, data.executionId, data.duration, data.rendererId);
if (data.mimeType && data.outputSize && data.rendererId === 'vscode.builtin-renderer') {
this._sendPerformanceData(data.mimeType, data.outputSize, data.duration);
}
break;
}
case 'outputInputFocus': {
Expand All @@ -927,6 +930,30 @@ export class BackLayerWebView<T extends ICommonCellInfo> extends Themable {
return initializePromise.p;
}

private _sendPerformanceData(mimeType: string, outputSize: number, renderTime: number) {
type NotebookOutputRenderClassification = {
owner: 'amunger';
comment: 'Track performance data for output rendering';
mimeType: { classification: 'SystemMetaData'; purpose: 'FeatureInsight'; comment: 'Presentation type of the output.' };
outputSize: { classification: 'SystemMetaData'; purpose: 'FeatureInsight'; comment: 'Size of the output data buffer.'; isMeasurement: true };
renderTime: { classification: 'SystemMetaData'; purpose: 'FeatureInsight'; comment: 'Time spent rendering output.'; isMeasurement: true };
};

type NotebookOutputRenderEvent = {
mimeType: string;
outputSize: number;
renderTime: number;
};

const telemetryData = {
mimeType,
outputSize,
renderTime
};

this.telemetryService.publicLog2<NotebookOutputRenderEvent, NotebookOutputRenderClassification>('NotebookCellOutputRender', telemetryData);
}

private _handleNotebookCellResource(uri: URI) {
const notebookResource = uri.path.length > 0 ? uri : this.documentUri;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -485,6 +485,8 @@ export interface IPerformanceMessage extends BaseToWebviewMessage {
readonly cellId: string;
readonly duration: number;
readonly rendererId: string;
readonly outputSize?: number;
readonly mimeType?: string;
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2711,7 +2711,21 @@ async function webviewPreloads(ctx: PreloadContext) {
outputElement/** outputNode */.element.style.visibility = data.initiallyHidden ? 'hidden' : '';

if (!!data.executionId && !!data.rendererId) {
postNotebookMessage<webviewMessages.IPerformanceMessage>('notebookPerformanceMessage', { cellId: data.cellId, executionId: data.executionId, duration: Date.now() - startTime, rendererId: data.rendererId });
let outputSize: number | undefined = undefined;
let mimeType: string | undefined = undefined;
if (data.content.type === 1 /* extension */) {
outputSize = data.content.output.valueBytes.length;
mimeType = data.content.output.mime;
}

postNotebookMessage<webviewMessages.IPerformanceMessage>('notebookPerformanceMessage', {
cellId: data.cellId,
executionId: data.executionId,
duration: Date.now() - startTime,
rendererId: data.rendererId,
outputSize,
mimeType
});
}
}

Expand Down

0 comments on commit 8f218ce

Please sign in to comment.