Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[analyzer] Don't ask for subtypes for the same elements several times…
… when searching for references When asking for all references of a member it starts by finding all supertypes for the class, then for each supertype (including itself) (that has a member with the same name as the one we're querying for) it searches for all subtypes. We recall that when getting all subtypes, it really gets all direct subtypes, then for each of those, their direct subtypes etc. Naturally, then, with getting all subtypes for all supertypes we will often ask for all direct subtypes of the same class several times. In fact, it's O(n^2): As an example, if asking for references to `foo` on this (in a file in analyzer, with 8 workspaces): ``` class X0 { void foo() { print('hello'); } } class X1 extends X0 { void foo() { print('hello'); } } class X2 extends X1 { void foo() { print('hello'); } } [...] class X149 extends X148 { void foo() { print('hello'); } } ``` we ask for subtypes 90600 (150 classes * 151 / 2 * 8 workspaces) times. This CL stops that from happening and in the example from above we "only" asks for subtypes 1200 (150 classes * 8 workspaces) times. For the `newFile` from `AbstractSingleUnitTest` example, for instance, we go from 28,264 asks to 17,432 asks (a ~38% reduction). Non-first runtimes when asking for references: Before: 0:00:03.074853 0:00:03.021881 0:00:03.034707 0:00:03.115596 0:00:03.032574 After: 0:00:02.223978 0:00:02.149937 0:00:02.150236 0:00:02.104704 0:00:02.175859 Difference at 95.0% confidence -0.894979 +/- 0.060283 -29.2867% +/- 1.97266% (Student's t, pooled s = 0.0413338) Change-Id: Id792a595e74de01c7186ab1263c38728f051f603 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/272623 Commit-Queue: Jens Johansen <jensj@google.com> Reviewed-by: Konstantin Shcheglov <scheglov@google.com> Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
- Loading branch information
Showing
8 changed files
with
109 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters