-
Notifications
You must be signed in to change notification settings - Fork 2k
Completion should take <16ms most of the time #7542
Copy link
Copy link
Open
Labels
A-completionautocompletionautocompletionA-perfperformance issuesperformance issuesE-has-instructionsIssue has some instructions and pointers to code to get startedIssue has some instructions and pointers to code to get startedS-actionableSomeone could pick this issue up and work on it right nowSomeone could pick this issue up and work on it right nowfunA technically challenging issue with high impactA technically challenging issue with high impactgood first issue
Metadata
Metadata
Assignees
Labels
A-completionautocompletionautocompletionA-perfperformance issuesperformance issuesE-has-instructionsIssue has some instructions and pointers to code to get startedIssue has some instructions and pointers to code to get startedS-actionableSomeone could pick this issue up and work on it right nowSomeone could pick this issue up and work on it right nowfunA technically challenging issue with high impactA technically challenging issue with high impactgood first issue
Type
Fields
Give feedbackNo fields configured for issues without a type.
Code completion performance is more important than it seems. Obviously, completion shouldn't take a second or two. But even for "almost instant" completion, theres' a huge difference in experience when going 300ms -> 150ms -> 50 ms -> 16ms. It's difficult to perceive such small differences by just eyeballing a single completion, but it does affect fluency of typing a lot.
Historically, we haven't payed much attention to completion, barring obvious regressions. It was, and it is, generally fast enough. But it seems like we are at the point where it makes sense to push performance here a bit.
The 16ms is the boundary such that it doesn't make much sense to go beyond it (as thats comparable to typing latency), and which should be achievable. The size of the result is small, and the work should be roughly linear in the size of the result.
The best way to start here is to set this config:
and check Code's output panel for profiling info, which looks like this:
Keep in mind that rust-analyzer employes lazy evaluation. That means that if both
fandgcalls, andsis slow, thenstime will be attributed to eitherforgdepending on their relative order.Another place to look at is the end-to-end request flow in the main loop. Profiling captures only the computation, but it's important that completion is not blocked by other requests.
It would also be sweet to implement some maintainable benchmarks here. This would have high impact, but I don't know how to best approach this.
Other that that, just look at the core with the profiler and try to make slow things faster!