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

Add AST module caching support to the LSP. #4988

Closed
wants to merge 1 commit into from

Conversation

tritao
Copy link
Contributor

@tritao tritao commented Aug 21, 2023

Description

This adds AST module caching support to the LSP.

Checklist

  • I have linked to any relevant issues.
  • I have commented my code, particularly in hard-to-understand areas.
  • I have updated the documentation where relevant (API docs, the reference, and the Sway book).
  • I have added tests that prove my fix is effective or that my feature works.
  • I have added (or requested a maintainer to add) the necessary Breaking* or New Feature labels where relevant.
  • I have done my best to ensure that my PR adheres to the Fuel Labs Code Review Standards.
  • I have requested a review from the relevant team or maintainers.

@tritao tritao mentioned this pull request Aug 21, 2023
7 tasks
@tritao tritao self-assigned this Oct 25, 2023
@JoshuaBatty
Copy link
Member

I've taken these commits and added them into #5251. Closing this in favour of that PR.

@JoshuaBatty JoshuaBatty closed this Nov 2, 2023
JoshuaBatty added a commit that referenced this pull request Nov 10, 2023
## Description
This PR supersedes #4988 and builds on backend work done by @tritao in
#4733.

A new `ModuleId` is created for each compiled module. The `SourceId`
type now also stores the `ModuleId` that was used to create it. This
allows us to perform garbage collection on types in the Declaration and
Type engines that refer the provided module.

```rust
if let Some(module_id) = engines.se().get_module_id(&path) {
    engines.clear_module(&module_id);
}
```

This method isn't super cheap to call. My tests had this averaging at
54ms. We are currently performing garbage collection on every key stroke
in LSP. We should look to have another metric such as only clearing once
every 20 keystrokes or so in the future.

I ran benchmarking on recompiling the `doc_comments` example 20 times to
simulate rapid keystrokes during coding. Here are the results.

| Without Caching | With Caching |
|---------------------|------------------|
| 89.489 s             | 4.6236  s         |

A speed up of 1835.49% is certainly great, yet 4.6 seconds still sounds
like an eternity. Still have lots of room to improve but this should
improve our current system dramatically.

closes #4994

Co-authored-by: Joao Matos <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants