Commit 9f42ef7
[analyzer] Add "interactive" option to "getResolvedUnit"; "setSubscriptions" are not; non-interactive ones have less priority
The legacy_many_files_in_flutter_set_subscriptions benchmark shows how
"flutter.setSubscriptions" calls can make the analyzer slower to
respond.
What happens is this:
* The user opens a new file in the IDE.
* The IDE sends the `flutter.setSubscriptions` request which equates to
a call to `getResolvedUnit` for each file in the request. If this is,
say, 300 files it's 300 calls to `getResolvedUnit`.
* The IDE sends a `edit.getAssists` request for the newly opened file.
This request starts processing, reaches `getResolvedLibrary(file)`
which calls `getUnitElement` ultimately adding the path to
`_unitElementRequestedFiles` which in `performWork` is done _after_
`_requestedFiles`, meaning it has to do all the flutter requested
files first.
* The user might then request completion for instance, but because the
analyzer only processes one request at a time it has to wait for the
`edit.getAssists` request to finish first, which had to wait for the
files from the `flutter.setSubscriptions` request to process.
All in all it's a lot of waiting for the user.
This CL adds a `interactive` option to the `getResolvedUnit` call. It
defaults to true in which case files are still added to
`_requestedFiles` and processed the same. If it's false it will instead
be added to a newly introduced list instead and processed at a lower
priority. Subscription requests are changed to pass `false` to
`interactive`, avoiding the scenario above.
Comparing before this CL with this CL on the
"legacy_many_files_in_flutter_set_subscriptions" benchmark with 100
files / CodeType.ImportChain these are the statistics on the changes
based on 5 runs each:
```
Completion after open of new file: -81.6652% +/- 7.7564% (-3.70 +/- 0.35) (4.53 -> 0.83)
getAssists call: -96.6315% +/- 0.9307% (-3.61 +/- 0.03) (3.74 -> 0.13)
peak virtual memory size: -5.6786% +/- 3.2964% (-139.00 +/- 80.69) (2447.80 -> 2308.80)
total program size (virtual): -4.6387% +/- 3.8146% (-110.80 +/- 91.11) (2388.60 -> 2277.80)
```
Even when flutter/flutter-intellij#7980 is
hopefully fixed I think it is a fair change to de-prioritize a
non-interactive request.
Change-Id: Icba2faebf12f9913cf24db7cb90fdc6f4c74164e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/418020
Reviewed-by: Brian Wilkerson <[email protected]>
Commit-Queue: Jens Johansen <[email protected]>1 parent f6fcd37 commit 9f42ef7
File tree
3 files changed
+42
-4
lines changed- pkg
- analysis_server/lib/src
- analyzer/lib/src/dart/analysis
3 files changed
+42
-4
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
793 | 793 | | |
794 | 794 | | |
795 | 795 | | |
| 796 | + | |
796 | 797 | | |
797 | 798 | | |
798 | 799 | | |
| |||
804 | 805 | | |
805 | 806 | | |
806 | 807 | | |
807 | | - | |
| 808 | + | |
| 809 | + | |
| 810 | + | |
| 811 | + | |
| 812 | + | |
808 | 813 | | |
809 | 814 | | |
810 | 815 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1190 | 1190 | | |
1191 | 1191 | | |
1192 | 1192 | | |
1193 | | - | |
| 1193 | + | |
1194 | 1194 | | |
1195 | 1195 | | |
1196 | 1196 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
182 | 182 | | |
183 | 183 | | |
184 | 184 | | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
185 | 191 | | |
186 | 192 | | |
187 | 193 | | |
| |||
494 | 500 | | |
495 | 501 | | |
496 | 502 | | |
| 503 | + | |
| 504 | + | |
| 505 | + | |
| 506 | + | |
497 | 507 | | |
498 | 508 | | |
499 | 509 | | |
| |||
525 | 535 | | |
526 | 536 | | |
527 | 537 | | |
| 538 | + | |
528 | 539 | | |
529 | 540 | | |
530 | 541 | | |
| |||
736 | 747 | | |
737 | 748 | | |
738 | 749 | | |
| 750 | + | |
| 751 | + | |
| 752 | + | |
| 753 | + | |
| 754 | + | |
| 755 | + | |
| 756 | + | |
739 | 757 | | |
740 | 758 | | |
741 | 759 | | |
| |||
1059 | 1077 | | |
1060 | 1078 | | |
1061 | 1079 | | |
1062 | | - | |
| 1080 | + | |
1063 | 1081 | | |
1064 | 1082 | | |
1065 | 1083 | | |
| |||
1091 | 1109 | | |
1092 | 1110 | | |
1093 | 1111 | | |
1094 | | - | |
| 1112 | + | |
| 1113 | + | |
| 1114 | + | |
| 1115 | + | |
| 1116 | + | |
1095 | 1117 | | |
1096 | 1118 | | |
1097 | 1119 | | |
| |||
1245 | 1267 | | |
1246 | 1268 | | |
1247 | 1269 | | |
| 1270 | + | |
| 1271 | + | |
| 1272 | + | |
| 1273 | + | |
| 1274 | + | |
| 1275 | + | |
1248 | 1276 | | |
1249 | 1277 | | |
1250 | 1278 | | |
| |||
1412 | 1440 | | |
1413 | 1441 | | |
1414 | 1442 | | |
| 1443 | + | |
| 1444 | + | |
1415 | 1445 | | |
1416 | 1446 | | |
1417 | 1447 | | |
| |||
1517 | 1547 | | |
1518 | 1548 | | |
1519 | 1549 | | |
| 1550 | + | |
| 1551 | + | |
| 1552 | + | |
1520 | 1553 | | |
1521 | 1554 | | |
1522 | 1555 | | |
| |||
0 commit comments