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

[CP] Cherry-pick for restoring using available declarations for completion #47285

Closed
scheglov opened this issue Sep 24, 2021 · 3 comments
Closed
Labels
analyzer-completion Issues with the analysis server's code completion feature analyzer-server area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. cherry-pick-approved Label for approved cherrypick request

Comments

@scheglov
Copy link
Contributor

scheglov commented Sep 24, 2021

commit(s) to merge: 6207d1d

merge instructions: clean (auto)merge

What is the issue: Computing completion suggestions, when the target library imports libraries that have a lot (thousands) of completion suggestions, is expensive.

What is the fix: The fix is to restore using available declarations feature. In short, we pre-compute and send sets of all declarations in any library that we know about, and at completion request we don't send suggestions for these libraries, we only send the corresponding set ID. This way we compute, and transfer 10x less data.

Why cherrypick: Many users impacted, anyone using Flutter.

Risk: low

Link to original issue(s):
flutter/flutter-intellij#5761

/cc @kevmoo @mit-mit @whesse @athomas @vsmenon @devoncarew

Currently 174 ms to just ask for completion:

1632505265214:Req:{"id"::"32","method"::"completion.getSuggestions","params"::{"file"::"/Users/scheglov/Source/flutter/examples/hello_world/lib/test.dart","offset"::132},
1632505265215:Res:{"id"::"32","result"::{"id"::"14"}}
1632505265299:Noti:{"event"::"completion.existingImports","params"::{"file"::"/Users/scheglov/Source/flutter/examples/hello_world/lib/test.dart","imports"::{"elements"::{
1632505265388:Noti:{"event"::"completion.results","params"::{"id"::"14","replacementOffset"::132,"replacementLength"::0,"results"::[{"kind"::"INVOCATION","relevance"::504

Currently 426 ms when typing M:

1632505689416:Req:{"id"::"59","method"::"completion.getSuggestions","params"::{"file"::"/Users/scheglov/Source/flutter/examples/hello_world/lib/test.dart","offset"::133},
1632505689417:Noti:{"event"::"server.status","params"::{"analysis"::{"isAnalyzing"::true}}}
1632505689507:Res:{"id"::"59","result"::{"id"::"25"}}
1632505689508:Noti:{"event"::"analysis.errors","params"::{"file"::"/Users/scheglov/Source/flutter/examples/hello_world/lib/test.dart","errors"::[{"severity"::"INFO","type
1632505689728:Noti:{"event"::"completion.existingImports","params"::{"file"::"/Users/scheglov/Source/flutter/examples/hello_world/lib/test.dart","imports"::{"elements"::{
1632505689842:Noti:{"event"::"completion.results","params"::{"id"::"25","replacementOffset"::132,"replacementLength"::1,"results"::[{"kind"::"INVOCATION","relevance"::504

With CP 7 ms to just ask for completion:

1632505843052:Req:{"id"::"22","method"::"completion.getSuggestions","params"::{"file"::"/Users/scheglov/Source/flutter/examples/hello_world/lib/test.dart","offset"::132},
1632505843053:Res:{"id"::"22","result"::{"id"::"13"}}
1632505843057:Noti:{"event"::"completion.existingImports","params"::{"file"::"/Users/scheglov/Source/flutter/examples/hello_world/lib/test.dart","imports"::{"elements"::{
1632505843059:Noti:{"event"::"completion.results","params"::{"id"::"13","replacementOffset"::132,"replacementLength"::0,"results"::[{"kind"::"KEYWORD","relevance"::501,"c

With CP 115 ms when typing M:

1632505955583:Req:{"id"::"56","method"::"completion.getSuggestions","params"::{"file"::"/Users/scheglov/Source/flutter/examples/hello_world/lib/test.dart","offset"::133},
1632505955584:Noti:{"event"::"server.status","params"::{"analysis"::{"isAnalyzing"::true}}}
1632505955691:Res:{"id"::"56","result"::{"id"::"22"}}
1632505955692:Noti:{"event"::"analysis.errors","params"::{"file"::"/Users/scheglov/Source/flutter/examples/hello_world/lib/test.dart","errors"::[{"severity"::"INFO","type
1632505955696:Noti:{"event"::"completion.existingImports","params"::{"file"::"/Users/scheglov/Source/flutter/examples/hello_world/lib/test.dart","imports"::{"elements"::{
1632505955698:Noti:{"event"::"completion.results","params"::{"id"::"22","replacementOffset"::132,"replacementLength"::1,"results"::[{"kind"::"KEYWORD","relevance"::501,"c

Note, that actual times are even higher because we measured here only times to compute in DAS, but don't include times to transfer data via stdout, and time to decode this data in IntelliJ. Without available declarations we these times are proportionally higher, probably pushing total completion time beyond 1000 ms, much longer than the target 100 ms.

@scheglov scheglov added area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. analyzer-completion Issues with the analysis server's code completion feature analyzer-server cherry-pick-review Issue that need cherry pick triage to approve labels Sep 24, 2021
@vsmenon
Copy link
Member

vsmenon commented Sep 28, 2021

approved

@vsmenon vsmenon added the cherry-pick-approved Label for approved cherrypick request label Sep 28, 2021
@devoncarew devoncarew removed the cherry-pick-review Issue that need cherry pick triage to approve label Sep 28, 2021
@athomas
Copy link
Member

athomas commented Sep 29, 2021

Merged to stable in 020b3ef (2.14.3).

@athomas athomas closed this as completed Sep 29, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
analyzer-completion Issues with the analysis server's code completion feature analyzer-server area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. cherry-pick-approved Label for approved cherrypick request
Projects
None yet
Development

No branches or pull requests

4 participants