Skip to content

Allow a single Engines to be used across a workspace #5856

Closed
@JoshuaBatty

Description

@JoshuaBatty

I'm currently helping Fluid Protocol debug bad LSP performance on their workspace. The workspace had 20+ sway projects and 1 large "libraries" project that contain 20+ sway libraries.

When clicking through the various projects, I've noticed that the amount of RAM used can easily reach 20+ gig. It seems we are recompiling std / core and shared libraries for each project. So if we click through all 20 projects, we have compiled the std lib 20 times and store it in the servers memory. For example, if we put a print in the following query engine code

pub fn insert_programs_cache_entry(&self, entry: ProgramsCacheEntry) {
    eprintln!("👷 Instering programs cache entry: {:?}", entry.path);
    let mut cache = self.programs_cache.write().unwrap();
    cache.insert(entry.path.clone(), entry);
}

We get the below.

Screenshot 2024-04-15 at 1 30 43 pm

Instead, we should be having a single QueryEngine stored in ServerState that is used across each project. This way we will be able to drastically reduce the memory footprint for projects like this, and greatly speed up the time it takes for the server to initialise when a new project is navigated to.

Metadata

Metadata

Assignees

Labels

bigthis task is hard and will take a whilecompiler: frontendEverything to do with type checking, control flow analysis, and everything between parsing and IRgenlanguage serverLSP serverteam:compilerCompiler Team

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions