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

Fix function_cache garbage collection bug #6555

Merged
merged 10 commits into from
Sep 18, 2024
Merged

Conversation

JoshuaBatty
Copy link
Member

@JoshuaBatty JoshuaBatty commented Sep 17, 2024

Description

Fixes a bug that would crash the language server when a function node was part of the AST.

#5967 added a function cache to the QueryEngine. Garbage collection needed to be called on this otherwise it returns references to types that have been cleared from the other engines during garbage collection.

In the future, any other nodes that we decide to cache need to have GC applied to them or we will end up crashing the language server on the first key-pressed event.

I've also removed the gc_frequency setting and now run GC on each keystroke. Without doing this, the spans stored in the TokenMap and what was returned from the compiler were falling out of sync. This ensures that everything is always up to date and the correct spans are used. closes #5260

Finally, I've added a launch.json that allows for attaching lldb to a live running forc-lsp process. This was a pretty cruical step for tracking down this bug so would be nice to have it easily accessible for future debugging sessions.

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.

@JoshuaBatty JoshuaBatty requested review from a team as code owners September 17, 2024 04:16
@JoshuaBatty JoshuaBatty added bug Something isn't working language server LSP server compiler: frontend Everything to do with type checking, control flow analysis, and everything between parsing and IRgen labels Sep 17, 2024
@JoshuaBatty JoshuaBatty self-assigned this Sep 17, 2024
@JoshuaBatty JoshuaBatty marked this pull request as draft September 17, 2024 04:17
Copy link

codspeed-hq bot commented Sep 17, 2024

CodSpeed Performance Report

Merging #6555 will degrade performances by 18.37%

Comparing josh/fix_function_slab_gc (cddd31a) with master (e82c72b)

Summary

❌ 1 regressions
✅ 21 untouched benchmarks

⚠️ Please fix the performance issues or acknowledge them on CodSpeed.

Benchmarks breakdown

Benchmark master josh/fix_function_slab_gc Change
document_symbol 4.3 ms 5.3 ms -18.37%

@JoshuaBatty JoshuaBatty changed the title Fix function_slab garbage collection bug Fix function_cache garbage collection bug Sep 17, 2024
@JoshuaBatty JoshuaBatty marked this pull request as ready for review September 17, 2024 05:07
alfiedotwtf
alfiedotwtf previously approved these changes Sep 17, 2024
@JoshuaBatty JoshuaBatty requested a review from a team September 17, 2024 05:30
@JoshuaBatty JoshuaBatty requested a review from a team September 17, 2024 07:33
@tritao
Copy link
Contributor

tritao commented Sep 17, 2024

Nice sleuthing on this

Copy link
Member

@sdankel sdankel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work!

Copy link
Member

@mchristopher mchristopher left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Small thing to confirm, otherwise looks great

@JoshuaBatty
Copy link
Member Author

Thanks, i'm going to merge this PR and then follow up with the suggestions for the launch.json file in a follow up PR.

@JoshuaBatty JoshuaBatty merged commit 1305b24 into master Sep 18, 2024
41 checks passed
@JoshuaBatty JoshuaBatty deleted the josh/fix_function_slab_gc branch September 18, 2024 08:18
kayagokalp pushed a commit that referenced this pull request Sep 18, 2024
## Description
Bumps repo to v0.63.6

waiting on #6555
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working compiler: frontend Everything to do with type checking, control flow analysis, and everything between parsing and IRgen language server LSP server
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Optimize how often we call garbage collection in the language server
6 participants