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

Cache BuildPlan in LSP #5462

Closed
kayagokalp opened this issue Jan 12, 2024 · 0 comments · Fixed by #6281
Closed

Cache BuildPlan in LSP #5462

kayagokalp opened this issue Jan 12, 2024 · 0 comments · Fixed by #6281
Assignees
Labels
enhancement New feature or request forc-pkg Everything related to the `forc-pkg` crate. language server LSP server

Comments

@kayagokalp
Copy link
Member

kayagokalp commented Jan 12, 2024

In an offline chat with @FuelLabs/tooling, it is stated that LSP spends considerable amount of time while dealing with build plan generation as forc-pkg does not offer an in memory representation for manifest files (it expects to read them from disk). One option is refactoring forc-pkg such that we can give it a in-memory manifests instead to remove expensive I/O operations. Although this might be a good refactor in the future, we realized that we can actually cache the build plan entirely for LSP purposes as the build plan won't be changing in any type of key stroke (other than the ones being appleid to a manifest file for the current workspace/project). So we can cache it entirely and do not need to regenerate for each keystroke.

  1. Generate the build plan once the project is open
  2. Cache it and use it from cache for each key stroke going forward
  3. Invalidate the cache if user touches a manifest file that belongs to the current list of manifest files in the cached build plan as that is the only to invalidate it.
@kayagokalp kayagokalp added enhancement New feature or request language server LSP server forc-pkg Everything related to the `forc-pkg` crate. labels Jan 12, 2024
@JoshuaBatty JoshuaBatty self-assigned this Jul 19, 2024
esdrubal pushed a commit that referenced this issue Aug 13, 2024
## Description
closes #5462
related #5445

before we were recreating the build plan on every keystroke. We now
cache the result and reuse on subsequent did change events. We
invalidate the cache if there has been any modifications to the
`Forc.toml` file since the cache was created.

Here are the timings when triggering this with a did_change event on the
FUSD repo.

previous: `80.146ms`
with this change: `56µs`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request forc-pkg Everything related to the `forc-pkg` crate. language server LSP server
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants