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

Significant TokenMap optimisation by removing clones and returning refs instead. #5509

Merged
merged 7 commits into from
Jan 25, 2024

Conversation

JoshuaBatty
Copy link
Member

@JoshuaBatty JoshuaBatty commented Jan 23, 2024

Description

This PR refactors the functions implemented on TokenMap to remove clones where possible, and instead return the RefMulti type from DashMap directly. As can be seen below, we are getting significant performance wins and most LSP capabilities are now measured in µs. 🚀

related to #5445

Metric Before After Change (%)
tokens_for_file 9.8117 ms 253.845 µs -97.411%
idents_at_position 3.6331 ms 47.870 µs -98.692%
tokens_at_position 6.9532 ms 1.1478 ms -83.474%
token_at_position 5.9395 ms 208.23 µs -96.483%
parent_decl_at_position 6.9780 ms 1.1633 ms -83.428%
semantic_tokens 18.2205 ms 587.64 µs -96.767%
document_symbol 6.6865 ms 584.33 µs -91.186%
completion 14.0025 ms 1.9808 ms -85.855%
hover 6.2409 ms 317.90 µs -94.902%
highlight 14.8390 ms 2.7572 ms -81.417%
goto_definition 5.9403 ms 225.65 µs -96.204%
inlay_hints 5.9934 ms 318.41 µs -94.677%
prepare_rename 5.8056 ms 207.62 µs -96.411%
rename 12.5200 ms 2.8592 ms -77.168%
code_action 11.0798 ms 1.9683 ms -82.233%

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 January 23, 2024 23:23
@JoshuaBatty JoshuaBatty self-assigned this Jan 23, 2024
@JoshuaBatty JoshuaBatty added the language server LSP server label Jan 23, 2024
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.

These performance gains are fantastic! Nice work 🚀

@JoshuaBatty JoshuaBatty requested a review from a team January 24, 2024 00:11
@JoshuaBatty JoshuaBatty enabled auto-merge (squash) January 24, 2024 00:12
@JoshuaBatty JoshuaBatty requested review from tritao and a team January 24, 2024 22:03
@tritao
Copy link
Contributor

tritao commented Jan 25, 2024

Nice work, amazing performance gains 🚀

@JoshuaBatty JoshuaBatty merged commit 4d98a5f into master Jan 25, 2024
35 checks passed
@JoshuaBatty JoshuaBatty deleted the josh/return_refs branch January 25, 2024 23:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants