Skip to content

Commit 949c899

Browse files
authored
Performance measurements of Notebooks (#15585)
* Perf tests for general notebook & kernel execution * Fix formatting
1 parent eda29e7 commit 949c899

33 files changed

+3158
-152
lines changed

.github/workflows/build-test.yml

Lines changed: 55 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -275,13 +275,14 @@ jobs:
275275
# When installing pre-release versions, we're only focused on jupyter & related packages.
276276
# Not pre-release versions of pandas, numpy or other such packages that are not core to Jupyter.
277277
packageVersion: ['']
278-
tags:
279-
[
278+
tags: [
280279
'^[^@]+$|@mandatory|@kernelCore|@python|@jupyter',
281280
'@widgets',
282281
'@iw',
283282
'@webview|@export|@lsp|@variableViewer',
284-
'@debugger'
283+
'@debugger',
284+
# '@notebookPerformance', # Disabled for now, separate PR this will be enabled via cron (want to make PR smaller)
285+
'@executionPerformance'
285286
]
286287
# We're not running CI on macOS for now because it's one less matrix entry to lower the number of runners used,
287288
# macOS runners are expensive, and we assume that Ubuntu is enough to cover the UNIX case.
@@ -506,7 +507,7 @@ jobs:
506507
# debugpy is not shipped, only installed for local tests.
507508
# In production, we get debugpy from python extension.
508509
- name: Install Python Libs
509-
if: matrix.python != 'conda' && matrix.python != 'noPython' && matrix.ipywidgetsVersion != '8'
510+
if: matrix.python != 'conda' && matrix.python != 'noPython' && matrix.ipywidgetsVersion != '8' && matrix.tags != '@notebookPerformance'
510511
run: |
511512
python --version
512513
python -c "import sys;print(sys.executable)"
@@ -521,7 +522,7 @@ jobs:
521522
python -m pip install jupyterlab notebook
522523
523524
- name: Install Python Libs (IPyWidget 8)
524-
if: matrix.python != 'conda' && matrix.python != 'noPython' && matrix.ipywidgetsVersion == '8'
525+
if: matrix.python != 'conda' && matrix.python != 'noPython' && matrix.ipywidgetsVersion == '8' && matrix.tags != '@notebookPerformance'
525526
run: |
526527
python --version
527528
python -c "import sys;print(sys.executable)"
@@ -542,7 +543,7 @@ jobs:
542543
543544
- name: Install matplotlib widgets into user and system paths
544545
if:
545-
matrix.os == 'ubuntu-latest' && matrix.python != 'conda' && matrix.python != 'noPython' && matrix.packageVersion != 'prerelease' && matrix.tags != '^[^@]+$|@mandatory'
546+
matrix.os == 'ubuntu-latest' && matrix.python != 'conda' && matrix.python != 'noPython' && matrix.packageVersion != 'prerelease' && matrix.tags != '^[^@]+$|@mandatory' && matrix.tags != '@notebookPerformance'
546547
# This test will ensure widgets work when installed in 3 places
547548
# 1. In python environments site-packages folder (we have other 3rd party widgets in the python env)
548549
# 2. In user's home folder (ipympl will be installed in there)
@@ -585,23 +586,30 @@ jobs:
585586
VSC_JUPYTER_CI_SKIP_WEB_BUNDLE: 1
586587
VSC_JUPYTER_CI_FAST_COMPILATION: 1
587588

589+
- name: Compile Performance Test Extension
590+
if: matrix.tags == '@notebookPerformance'
591+
run: npm run compile
592+
working-directory: src/test/vscode-notebook-perf
593+
588594
# Used by tests for non-python kernels.
589595
# Test are enabled via env variable `VSC_JUPYTER_CI_RUN_NON_PYTHON_NB_TEST`
590596
- name: Install Deno
591597
uses: denoland/setup-deno@v1
598+
if: matrix.tags != '@notebookPerformance'
592599
with:
593600
deno-version: ${{ env.DENO_VERSION}}
594601

595602
- name: Install Deno Kernel
603+
if: matrix.tags != '@notebookPerformance'
596604
run: npx tsx ./build/installDenoKernel.ts
597605

598606
- name: Create Virtual Env for Tests
599607
uses: ./.github/actions/create-venv-for-tests
600-
if: matrix.python != 'conda' && matrix.python != 'noPython' && matrix.os != 'windows-latest' && matrix.jupyterConnection != 'remote' && matrix.tags != '^[^@]+$|@mandatory' && matrix.ipywidgetsVersion != '8' && matrix.jupyterConnection != 'web' && matrix.jupyterConnection != 'remote' && matrix.tags != '@debugger' && matrix.tags != '@webview|@export|@lsp|@variableViewer'
608+
if: matrix.python != 'conda' && matrix.python != 'noPython' && matrix.os != 'windows-latest' && matrix.jupyterConnection != 'remote' && matrix.tags != '^[^@]+$|@mandatory' && matrix.ipywidgetsVersion != '8' && matrix.jupyterConnection != 'web' && matrix.jupyterConnection != 'remote' && matrix.tags != '@debugger' && matrix.tags != '@webview|@export|@lsp|@variableViewer' && matrix.tags != '@notebookPerformance'
601609

602610
- name: Create Virtual Env for Tests (ipywidgets 8)
603611
uses: ./.github/actions/create-venv-for-tests
604-
if: matrix.python != 'conda' && matrix.python != 'noPython' && matrix.os != 'windows-latest' && matrix.jupyterConnection != 'remote' && matrix.tags != '^[^@]+$|@mandatory' && matrix.ipywidgetsVersion == '8' && matrix.jupyterConnection != 'web' && matrix.jupyterConnection != 'remote' && matrix.tags != '@debugger' && matrix.tags != '@webview|@export|@lsp|@variableViewer'
612+
if: matrix.python != 'conda' && matrix.python != 'noPython' && matrix.os != 'windows-latest' && matrix.jupyterConnection != 'remote' && matrix.tags != '^[^@]+$|@mandatory' && matrix.ipywidgetsVersion == '8' && matrix.jupyterConnection != 'web' && matrix.jupyterConnection != 'remote' && matrix.tags != '@debugger' && matrix.tags != '@webview|@export|@lsp|@variableViewer' && matrix.tags != '@notebookPerformance'
605613
with:
606614
IPyWidgetVersion: '8'
607615

@@ -646,7 +654,45 @@ jobs:
646654
VSC_JUPYTER_CI_TEST_VSC_CHANNEL: 'insiders'
647655
VSC_JUPYTER_CI_TEST_GREP: ${{ matrix.tags }}
648656
id: test_notebook_vscode_ubuntu
649-
if: matrix.python != 'noPython' && matrix.os == 'ubuntu-latest' && matrix.jupyterConnection != 'web'
657+
if: matrix.python != 'noPython' && matrix.os == 'ubuntu-latest' && matrix.jupyterConnection != 'web' && matrix.tags != '@notebookPerformance'
658+
659+
- name: Run Notebook Perf Test Without Jupyter
660+
uses: GabrielBB/[email protected]
661+
with:
662+
run: ${{ env.xvfbCommand }} npm run testPerfInVSCode
663+
env:
664+
VSC_JUPYTER_FORCE_LOGGING: 1
665+
VSC_PYTHON_FORCE_LOGGING: 1
666+
VSC_JUPYTER_CI_RUN_NON_PYTHON_NB_TEST: 1
667+
VSC_JUPYTER_PERF_TEST: ${{ matrix.matrix == '@notebookPerformance' }}
668+
VSC_JUPYTER_NOTEBOOK_PERF_TEST: ${{ matrix.matrix == '@notebookPerformance' }}
669+
VSC_JUPYTER_CI_TEST_DO_NOT_INSTALL_PYTHON_EXT: ${{ matrix.matrix == '@notebookPerformance' }}
670+
VSC_JUPYTER_REMOTE_NATIVE_TEST: ${{ matrix.jupyterConnection == 'remote' }}
671+
VSC_JUPYTER_NON_RAW_NATIVE_TEST: ${{ matrix.jupyterConnection == 'local' }}
672+
VSC_JUPYTER_CI_RUN_JAVA_NB_TEST: ${{ matrix.python == 'conda' }}
673+
VSC_JUPYTER_CI_IS_CONDA: ${{ matrix.python == 'conda' }}
674+
VSC_JUPYTER_CI_TEST_VSC_CHANNEL: 'insiders'
675+
VSC_JUPYTER_CI_TEST_GREP: ${{ matrix.tags }}
676+
id: test_notebook_perf_vscode_ubuntu
677+
if: matrix.tags == '@notebookPerformance'
678+
679+
- name: Run Execution Perf Test With Jupyter
680+
uses: GabrielBB/[email protected]
681+
with:
682+
run: ${{ env.xvfbCommand }} npm run testExecPerfInVSCode
683+
env:
684+
VSC_JUPYTER_FORCE_LOGGING: 1
685+
VSC_PYTHON_FORCE_LOGGING: 1
686+
VSC_JUPYTER_CI_RUN_NON_PYTHON_NB_TEST: 1
687+
VSC_JUPYTER_PERF_TEST: ${{ matrix.matrix == '@executionPerformance' }}
688+
VSC_JUPYTER_REMOTE_NATIVE_TEST: ${{ matrix.jupyterConnection == 'remote' }}
689+
VSC_JUPYTER_NON_RAW_NATIVE_TEST: ${{ matrix.jupyterConnection == 'local' }}
690+
VSC_JUPYTER_CI_RUN_JAVA_NB_TEST: ${{ matrix.python == 'conda' }}
691+
VSC_JUPYTER_CI_IS_CONDA: ${{ matrix.python == 'conda' }}
692+
VSC_JUPYTER_CI_TEST_VSC_CHANNEL: 'insiders'
693+
VSC_JUPYTER_CI_TEST_GREP: ${{ matrix.tags }}
694+
id: test_exec_perf_vscode_ubuntu
695+
if: matrix.tags == '@executionPerformance'
650696

651697
- name: Build web bundle for testing
652698
run: npm run compile-web-test

.vscode/launch.json

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,63 @@
302302
"XVSC_JUPYTER_INSTRUMENT_CODE_FOR_COVERAGE_HTML": "1" //Enable to get full coverage repor (in coverage folder).
303303
}
304304
},
305+
{
306+
"name": "Tests Notebook Performance without Jupyter & Python",
307+
"type": "extensionHost",
308+
"request": "launch",
309+
"runtimeExecutable": "${execPath}",
310+
"args": [
311+
"${workspaceFolder}/src/test/datascience",
312+
"--enable-proposed-api",
313+
"--disable-extensions",
314+
"--extensionDevelopmentPath=${workspaceFolder}/src/test/vscode-notebook-perf",
315+
"--extensionTestsPath=${workspaceFolder}/out/test/index.node.js"
316+
],
317+
"env": {
318+
"VSC_JUPYTER_PERF_TEST": "1",
319+
"VSC_JUPYTER_CI_TEST_GREP": "@notebookPerformance",
320+
"VSC_JUPYTER_CI_TEST_VSC_CHANNEL": "insiders",
321+
"TEST_FILES_SUFFIX": "*.vscode.common.test",
322+
"VSC_JUPYTER_CI_TEST_DO_NOT_INSTALL_PYTHON_EXT": "true"
323+
},
324+
"sourceMaps": true,
325+
"outFiles": [
326+
"${workspaceFolder}/out/**/*.js",
327+
"${workspaceFolder}/src/test/vscode-notebook-perf/out/**/*.js",
328+
"!${workspaceFolder}/**/node_modules**/*"
329+
],
330+
"skipFiles": ["<node_internals>/**"],
331+
"presentation": {
332+
"group": "2_tests",
333+
"order": 6
334+
}
335+
},
336+
{
337+
"name": "Tests Execution Performance with Jupyter & Python",
338+
"type": "extensionHost",
339+
"request": "launch",
340+
"runtimeExecutable": "${execPath}",
341+
"args": [
342+
"${workspaceFolder}/src/test/datascience",
343+
"--enable-proposed-api",
344+
"--extensionDevelopmentPath=${workspaceFolder}",
345+
"--extensionTestsPath=${workspaceFolder}/out/test/index.node.js"
346+
],
347+
"env": {
348+
"VSC_JUPYTER_PERF_TEST": "1",
349+
"VSC_JUPYTER_CI_TEST_GREP": "@executionPerformance",
350+
"VSC_JUPYTER_CI_TEST_VSC_CHANNEL": "insiders",
351+
"CI_PYTHON_PATH": "/Users/donjayamanne/Development/vsc/vscode-jupyter/.venv/bin/python",
352+
"TEST_FILES_SUFFIX": "*.vscode.test"
353+
},
354+
"sourceMaps": true,
355+
"outFiles": ["${workspaceFolder}/out/**/*.js", "!${workspaceFolder}/**/node_modules**/*"],
356+
"skipFiles": ["<node_internals>/**"],
357+
"presentation": {
358+
"group": "2_tests",
359+
"order": 6
360+
}
361+
},
305362
{
306363
"type": "node",
307364
"request": "launch",

package.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2108,6 +2108,10 @@
21082108
"testJediLSP": "node ./out/test/languageServers/jedi/lspSetup.js && cross-env CODE_TESTS_WORKSPACE=src/test VSC_JUPYTER_CI_TEST_GREP='Language Server:' node ./out/test/testBootstrap.node.js ./out/test/standardTest.node.js && node ./out/test/languageServers/jedi/lspTeardown.node.js",
21092109
"pretestNativeNotebooksInVSCode": "cross-env VSC_JUPYTER_CI_TEST_VSC_CHANNEL=insiders node ./out/test/datascience/dsTestSetup.js",
21102110
"testNativeNotebooksInVSCode": "cross-env CODE_TESTS_WORKSPACE=src/test/datascience VSC_JUPYTER_CI_TEST_VSC_CHANNEL=insiders TEST_FILES_SUFFIX=*.vscode.test,*.vscode.common.test VSC_JUPYTER_FORCE_LOGGING=1 node ./out/test/testBootstrap.node.js ./out/test/standardTest.node.js",
2111+
"pretestPerfInVSCode": "cross-env VSC_JUPYTER_CI_TEST_GREP=@notebookPerformance VSC_JUPYTER_CI_TEST_DO_NOT_INSTALL_PYTHON_EXT=true VSC_JUPYTER_PERF_TEST=1 VSC_JUPYTER_CI_TEST_VSC_CHANNEL=insiders node ./out/test/datascience/dsTestSetup.js",
2112+
"testPerfInVSCode": "cross-env VSC_JUPYTER_CI_TEST_GREP=@notebookPerformance VSC_JUPYTER_CI_TEST_DO_NOT_INSTALL_PYTHON_EXT=true VSC_JUPYTER_NOTEBOOK_PERF_TEST=true VSC_JUPYTER_PERF_TEST=1 CODE_TESTS_WORKSPACE=src/test/datascience VSC_JUPYTER_CI_TEST_VSC_CHANNEL=insiders TEST_FILES_SUFFIX=*.vscode.test,*.vscode.common.test VSC_JUPYTER_FORCE_LOGGING=1 node ./out/test/testBootstrap.node.js ./out/test/standardTest.node.js",
2113+
"pretestExecPerfInVSCode": "cross-env VSC_JUPYTER_CI_TEST_GREP=@executionPerformance VSC_JUPYTER_PERF_TEST=1 VSC_JUPYTER_CI_TEST_VSC_CHANNEL=insiders node ./out/test/datascience/dsTestSetup.js",
2114+
"testExecPerfInVSCode": "cross-env VSC_JUPYTER_CI_TEST_GREP=@executionPerformance VSC_JUPYTER_PERF_TEST=1 CODE_TESTS_WORKSPACE=src/test/datascience VSC_JUPYTER_CI_TEST_VSC_CHANNEL=insiders TEST_FILES_SUFFIX=*.vscode.test,*.vscode.common.test VSC_JUPYTER_FORCE_LOGGING= node ./out/test/testBootstrap.node.js ./out/test/standardTest.node.js",
21112115
"testNativeNotebooksInVSCodeWithoutTestSuffix": "cross-env CODE_TESTS_WORKSPACE=src/test/datascience VSC_JUPYTER_CI_TEST_VSC_CHANNEL=insiders VSC_JUPYTER_FORCE_LOGGING=1 node ./out/test/testBootstrap.node.js ./out/test/standardTest.node.js",
21122116
"pretestNativeNotebooksWithoutPythonInVSCode": "cross-env VSC_JUPYTER_CI_TEST_VSC_CHANNEL=insiders node ./out/test/datascience/dsTestSetup.js",
21132117
"testNativeNotebooksWithoutPythonInVSCode": "cross-env CODE_TESTS_WORKSPACE=src/test/datascience VSC_JUPYTER_CI_TEST_VSC_CHANNEL=insiders TEST_FILES_SUFFIX=*.vscode.test,*.vscode.common.test VSC_JUPYTER_FORCE_LOGGING=1 VSC_JUPYTER_CI_TEST_GREP=@nonPython VSC_JUPYTER_CI_TEST_DO_NOT_INSTALL_PYTHON_EXT=true node ./out/test/testBootstrap.node.js ./out/test/standardTest.node.js",

pvsc.code-workspace

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@
2121
{
2222
"name": "vscode-jupyter-powertoys",
2323
"path": "../vscode-jupyter-powertoys"
24+
},
25+
{
26+
"path": "src/test/vscode-notebook-perf"
2427
}
2528
],
2629
"settings": {

src/api.unstable.d.ts

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,18 @@
33

44
import type { CancellationToken, Disposable, Event, NotebookDocument, Uri } from 'vscode';
55
import type { Session } from '@jupyterlab/services';
6+
type EnvironmentPath = {
7+
/**
8+
* The ID of the environment.
9+
*/
10+
readonly id: string;
11+
/**
12+
* Path to environment folder or path to python executable that uniquely identifies an environment. Environments
13+
* lacking a python executable are identified by environment folder paths, whereas other envs can be identified
14+
* using python executable path.
15+
*/
16+
readonly path: string;
17+
};
618

719
declare module './api' {
820
export interface Jupyter {
@@ -32,10 +44,10 @@ declare module './api' {
3244
/**
3345
* Opens a notebook with a specific Python Environment as the active kernel.
3446
* @param {Uri} uri Uri of the notebook to open.
35-
* @param {String} kernelId Id of the Python Environment
47+
* @param {EnvironmentPath} pythonEnvironment Python Environment
3648
* @returns {Promise<NotebookDocument>} Promise that resolves to the notebook document.
3749
*/
38-
openNotebook(uri: Uri, pythonEnvironmentId: string): Promise<NotebookDocument>;
50+
openNotebook(uri: Uri, pythonEnvironment: EnvironmentPath): Promise<NotebookDocument>;
3951
/**
4052
* Opens a notebook with a specific kernel as the active kernel.
4153
* @param {Uri} uri Uri of the notebook to open.

0 commit comments

Comments
 (0)