Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
jmcphers opened this issue Apr 25, 2023 · 1 comment
Open
Labels
area: variables Issues related to Variables category.

Comments

@jmcphers
Copy link
Collaborator

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:

  • increasing memory consumption by accidentally forcing early evaluation
  • bumping reference counts unintentionally and preventing garbage collection
  • creating unnecessary copies of data during formatting and display
  • dramatically decreasing performance as a side effect of change detection or pathologically slow formatting
  • triggering inescapable debug loops (code evaluated during the course of building the pane triggers the debugger, which rebuilds the pane, which ...)

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:

  • bind the lifetime of the front end client instance to the UI widget (it's okay to repeatedly create and destroy these since they automatically send new lists when created); rely on the user to show/hide the pane as a way to enable/disable
  • imitate RStudio's feature and have a latch that turns off the back-end's introspection without otherwise altering the shape of the pane
  • run away from home and live in the woods
@jmcphers jmcphers added this to the Public Beta milestone Apr 25, 2023
@petetronic petetronic changed the title Provide a way to close or disable the Environment pane client Variables View: Provide a way to close or disable the Variables client Nov 23, 2023
@wesm wesm added the area: variables Issues related to Variables category. label Feb 29, 2024
@seeM
Copy link
Contributor

seeM commented May 22, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: variables Issues related to Variables category.
Projects
None yet
Development

No branches or pull requests

4 participants