Open JoshuaBatty opened 5 months ago
related to #5645
Ok it's not as simple as just having the QueryEngine
shared across workspace members. This will allow us to share the cached AST but the type and decl engines still need to be populated. What we probably want is to have the Engines
and other items like the TokenMap
stored in the ServerState
rather than within each Session
.
This is going to involve quite a bit of code re-arranging but should be feasible.
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
We get the below.
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.