posit-dev / positron

Positron, a next-generation data science IDE
Other
2.41k stars 71 forks source link

Variables View: Provide a way to close or disable the Variables client #507

Open jmcphers opened 1 year ago

jmcphers commented 1 year ago

The introspection and change detection done by the Environment pane can have unwanted side effects. These are all examples of problems that we have historically had:

Because it is not possible to close RStudio's Environment pane (it is effectively a singleton on both the client and the server), we built a feature into it that allows one to disable the auto-refresh feature. Users experiencing any of the above ill effects can thus turn it off to prevent (or at least rule out) the Environment pane as a source of trouble.

image

This is not currently possible in Positron. Positron's architecture does not use singletons, but does have a code-enforced 1:1 correspondence between Environment front ends and language runtimes: currently we create an Environment client for every language runtime, and host it in a headless service, attaching it to the UI in another layer.

https://github.com/rstudio/positron/blob/1d10e4283129cfcc2f492d56222611f784cd0036/src/vs/workbench/services/positronEnvironment/common/positronEnvironmentService.ts#L96-L116

This makes it impossible to disable the Environment features on the back end; we create the front end even if the UI is not visible, and it stays around even when the UI is closed.

We should provide a safety bypass somewhere to make it possible to work in a language runtime without the Environment pane active. Some possible approaches:

seeM commented 3 months ago

For example, this notebook runs in ~14 seconds when change detection is enabled in the Python kernel. When it's disabled, it runs in ~4 seconds (the same time taken in Jupyter Notebook with a standard ipykernel). That's 3.5x slower!

That said, the notebook uses from x import * which probably introduces more variables than a typical user would have.