Skip to content

Commit e743ade

Browse files
committed
Fix code lens perf for interactive window (#11142)
* Eliminate first level of redundancy * Working with a cache * Add test to verify no more generating cell ranges * Add news entry * Clean up on closing * Make sure close and reopen works * Fix sonar errors * Fix restart * Fix wrong IDisposable type * Rename restartedKernel to onKernelRestarted * Recompute when changing settings * Clear out document close event when document closes
1 parent e6c627c commit e743ade

27 files changed

+350
-199
lines changed

news/2 Fixes/10971.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fix perf problems after running the interactive window for an extended period of time.

src/client/datascience/cellFactory.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ export function hasCells(document: TextDocument, settings?: IDataScienceSettings
110110
}
111111

112112
// CellRange is used as the basis for creating new ICells. We only use it in this file.
113-
interface ICellRange {
113+
export interface ICellRange {
114114
range: Range;
115115
title: string;
116116
cell_type: string;

src/client/datascience/editor-integration/cellhashLogger.ts

Lines changed: 0 additions & 48 deletions
This file was deleted.

src/client/datascience/editor-integration/cellhashprovider.ts

Lines changed: 8 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,13 @@ import { noop } from '../../common/utils/misc';
1414
import { getCellResource } from '../cellFactory';
1515
import { CellMatcher } from '../cellMatcher';
1616
import { Identifiers } from '../constants';
17-
import { InteractiveWindowMessages, SysInfoReason } from '../interactive-common/interactiveWindowTypes';
1817
import {
1918
ICell,
2019
ICellHash,
2120
ICellHashListener,
2221
ICellHashProvider,
2322
IFileHashes,
24-
IInteractiveWindowListener
23+
INotebookExecutionLogger
2524
} from '../types';
2625

2726
interface IRangedCellHash extends ICellHash {
@@ -35,7 +34,7 @@ interface IRangedCellHash extends ICellHash {
3534
// This class provides hashes for debugging jupyter cells. Call getHashes just before starting debugging to compute all of the
3635
// hashes for cells.
3736
@injectable()
38-
export class CellHashProvider implements ICellHashProvider, IInteractiveWindowListener {
37+
export class CellHashProvider implements ICellHashProvider, INotebookExecutionLogger {
3938
// tslint:disable-next-line: no-any
4039
private postEmitter: EventEmitter<{ message: string; payload: any }> = new EventEmitter<{
4140
message: string;
@@ -71,25 +70,6 @@ export class CellHashProvider implements ICellHashProvider, IInteractiveWindowLi
7170
return this.postEmitter.event;
7271
}
7372

74-
// tslint:disable-next-line: no-any
75-
public onMessage(message: string, payload?: any): void {
76-
switch (message) {
77-
case InteractiveWindowMessages.AddedSysInfo:
78-
if (payload && payload.type) {
79-
const reason = payload.type as SysInfoReason;
80-
if (reason !== SysInfoReason.Interrupt) {
81-
this.hashes.clear();
82-
this.executionCount = 0;
83-
this.updateEventEmitter.fire();
84-
}
85-
}
86-
break;
87-
88-
default:
89-
break;
90-
}
91-
}
92-
9373
public getHashes(): IFileHashes[] {
9474
return [...this.hashes.entries()]
9575
.map((e) => {
@@ -101,6 +81,12 @@ export class CellHashProvider implements ICellHashProvider, IInteractiveWindowLi
10181
.filter((e) => e.hashes.length > 0);
10282
}
10383

84+
public onKernelRestarted() {
85+
this.hashes.clear();
86+
this.executionCount = 0;
87+
this.updateEventEmitter.fire();
88+
}
89+
10490
public async preExecute(cell: ICell, silent: boolean): Promise<void> {
10591
try {
10692
if (!silent) {

0 commit comments

Comments
 (0)