Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions news/2 Fixes/10170.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Perf improvements to executing startup code for `Data Science` features when extension loads.
1 change: 1 addition & 0 deletions news/3 Code Health/10176.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Track cold/warm times to execute notebook cells.
2 changes: 1 addition & 1 deletion src/client/datascience/activation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export class Activation implements IExtensionSingleActivationService {
this.disposables.push(this.jupyterInterpreterService.onDidChangeInterpreter(this.onDidChangeInterpreter, this));
// Warm up our selected interpreter for the extension
this.jupyterInterpreterService.setInitialInterpreter().ignoreErrors();
await this.contextService.activate();
this.contextService.activate().ignoreErrors();
}

private onDidOpenNotebookEditor(_: INotebookEditor) {
Expand Down
17 changes: 16 additions & 1 deletion src/client/datascience/interactive-ipynb/nativeEditor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ export class NativeEditor extends InteractiveBase implements INotebookEditor {
public get onDidChangeViewState(): Event<void> {
return this._onDidChangeViewState.event;
}
private sentExecuteCellTelemetry: boolean = false;
private _onDidChangeViewState = new EventEmitter<void>();
private closedEvent: EventEmitter<INotebookEditor> = new EventEmitter<INotebookEditor>();
private executedEvent: EventEmitter<INotebookEditor> = new EventEmitter<INotebookEditor>();
Expand Down Expand Up @@ -362,8 +363,10 @@ export class NativeEditor extends InteractiveBase implements INotebookEditor {
}

protected submitCode(code: string, file: string, line: number, id?: string, editor?: TextEditor, debug?: boolean): Promise<boolean> {
const stopWatch = new StopWatch();
const submitCodePromise = super.submitCode(code, file, line, id, editor, debug).finally(() => this.sendPerceivedCellExecute(stopWatch));
// When code is executed, update the version number in the metadata.
return super.submitCode(code, file, line, id, editor, debug).then(value => {
return submitCodePromise.then(value => {
this.updateVersionInfoInNotebook()
.then(() => {
this.metadataUpdatedEvent.fire(this);
Expand Down Expand Up @@ -513,6 +516,18 @@ export class NativeEditor extends InteractiveBase implements INotebookEditor {
// Actually don't close, just let the error bubble out
}

private sendPerceivedCellExecute(runningStopWatch?: StopWatch) {
if (runningStopWatch) {
const props = { notebook: true };
if (!this.sentExecuteCellTelemetry) {
this.sentExecuteCellTelemetry = true;
sendTelemetryEvent(Telemetry.ExecuteCellPerceivedCold, runningStopWatch.elapsedTime, props);
} else {
sendTelemetryEvent(Telemetry.ExecuteCellPerceivedWarm, runningStopWatch.elapsedTime, props);
}
}
}

/**
* Update the Python Version number in the notebook data.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ export class JupyterInterpreterSubCommandExecutionService implements IJupyterSub
}

if (productsNotInstalled.length === 1 && productsNotInstalled[0] === Product.kernelspec) {
return DataScience.jupyterKernelSpecModuleNotFound();
return DataScience.jupyterKernelSpecModuleNotFound().format(interpreter.path);
}

return getMessageForLibrariesNotInstalled(productsNotInstalled, interpreter.displayName);
Expand Down
3 changes: 0 additions & 3 deletions src/client/datascience/jupyter/kernels/kernelService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,6 @@ export class KernelService {
if (item.language.toLowerCase() !== PYTHON_LANGUAGE.toLowerCase()) {
return false;
}
if (item.display_name !== option.displayName) {
return false;
}
return this.fileSystem.arePathsSame(item.argv[0], option.path) || this.fileSystem.arePathsSame(item.metadata?.interpreter?.path || '', option.path);
});
} else {
Expand Down
12 changes: 10 additions & 2 deletions src/client/telemetry/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1459,8 +1459,16 @@ export interface IEventNamePropertyMapping {
[Telemetry.DisableInteractiveShiftEnter]: never | undefined;
[Telemetry.EnableInteractiveShiftEnter]: never | undefined;
[Telemetry.ExecuteCell]: never | undefined;
[Telemetry.ExecuteCellPerceivedCold]: never | undefined;
[Telemetry.ExecuteCellPerceivedWarm]: never | undefined;
/**
* Telemetry sent to capture first time execution of a cell.
* If `notebook = true`, this its telemetry for native editor/notebooks.
*/
[Telemetry.ExecuteCellPerceivedCold]: undefined | { notebook: boolean };
/**
* Telemetry sent to capture subsequent execution of a cell.
* If `notebook = true`, this its telemetry for native editor/notebooks.
*/
[Telemetry.ExecuteCellPerceivedWarm]: undefined | { notebook: boolean };
[Telemetry.ExecuteNativeCell]: never | undefined;
[Telemetry.ExpandAll]: never | undefined;
[Telemetry.ExportNotebook]: never | undefined;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ suite('Data Science - Jupyter InterpreterSubCommandExecutionService', () => {

const reason = await jupyterInterpreterExecutionService.getReasonForJupyterNotebookNotBeingSupported(undefined);

assert.equal(reason, DataScience.jupyterKernelSpecModuleNotFound());
assert.equal(reason, DataScience.jupyterKernelSpecModuleNotFound().format(selectedJupyterInterpreter.path));
});
test('Can start jupyer notebook', async () => {
const output = await jupyterInterpreterExecutionService.startNotebook([], {});
Expand Down