facebook / facebook/pyrefly

Garbage collection for orphaned/downgraded module data in LSP

Open
#2,637 0 comments 0 reactions 0 assignees View on GitHub
language-server needs-discussion performance
Dominant language
Rust
Stars
7k
Forks
516
PR merge metrics
No merged PRs in 30d

Description

### Describe the Bug

To the best of my knowledge once we load a module into the LSP state we do not free it once it has been orphaned.

For example, if we load some dependencies under one environment, and switch the interpreter/environment, we do not free the data for the old environment.

I do not know if we free the AST/answers for files we open outside of the project when we downgrade the requires level, if we for example go-to-def to a file in site packages and then close it.

The process of determining what's orphaned might be expensive so we may not want to do it on every invalidation. Maybe as a periodic background task?

### Sandbox Link

_No response_

### (Only applicable for extension issues) IDE Information

_No response_

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.