FuelLabs / sway

🌴 Empowering everyone to build reliable and efficient smart contracts.
https://docs.fuel.network/docs/sway/
Apache License 2.0
62.59k stars 5.37k forks source link

[Tracking] Reduce LSP Memory Footprint #6226

Open JoshuaBatty opened 4 months ago

JoshuaBatty commented 4 months ago

Tracking issue for reducing the large RAM usage of the language server.

tritao commented 3 months ago

Might be interesting to look into https://docs.rs/cstree/latest/cstree/, which implements some of the syntax tree design approaches initially presented by Roslyn (C# compiler) and Swift libsyntax.

Specifically:

cstree trees are trees over interned strings. This means cstree will deduplicate the text of tokens with the same source string, such as identifiers with the same name. In this position, rowan stores each token’s text together with its metadata as a custom DST (dynamically-sized type).

It would allow us to better intern and re-use parts of our syntax tree nodes.