[analyzer] Various optimizations

In total this shaves off a little over 900 mio instructions when
analyzing the CFE.

Changes:
* informative_data: _InfoBuilder._buildInstanceData - only go though members once
* informative_data: _InfoBuilder.build - only go though unit.directives once
* informative_data: _InfoBuilder.build - only go though unit.declarations once
* inheritance_manager3: Inline first part of _combineSignatures
* informative_data: Don't call withOriginDeclaration several times; don't turn iterators into lists to use them as iterators
* type_visitor: Don't create lists just to visit the content
* inheritance_manager3: Common cases of no substitutions and not covariance optimized; create a few less mostly unused lists
* element.dart: Don't create list to take a specific element

Detailed runtime breakdowns:

Runs of "pkg/analyzer/tool/stable_analysis.aot" with --no-fine-dependencies --no-lints --no-warnings --no-comments --silent run on the golem version of the cfe

Normal GC, 10 runs:

```
msec task-clock:u: -6.6412% +/- 1.1877% (-571.79 +/- 102.26) (8609.84 -> 8038.05)
page-faults:u: -0.5690% +/- 0.0662% (-907.90 +/- 105.67) (159559.80 -> 158651.90)
cycles:u: -6.9461% +/- 1.2300% (-2509675716.90 +/- 444394620.46) (36130860072.10 -> 33621184355.20)
instructions:u: -6.7293% +/- 0.0019% (-2944479732.50 +/- 814962.56) (43756250678.90 -> 40811770946.40)
branch-misses:u: -6.3244% +/- 5.6672% (-9863445.60 +/- 8838488.16) (155958035.20 -> 146094589.60)
seconds time elapsed: -6.6376% +/- 1.1880% (-0.57 +/- 0.10) (8.61 -> 8.04)
seconds user: -6.7709% +/- 1.2279% (-0.56 +/- 0.10) (8.30 -> 7.74)
maxRssKbytes: 0.7329% +/- 0.0215% (3698.00 +/- 108.58) (504581.60 -> 508279.60)
maxRssBytes: 0.7329% +/- 0.0215% (3786752.00 +/- 111181.19) (516691558.40 -> 520478310.40)

Comparing GC data:
Scavenge(   new space) goes from 135 to 131
MarkSweep(   promotion) goes from 16 to 14
MarkSweep(   old space) goes from 0 to 1
Notice combined GC time goes from 3070 ms to 2734 ms (notice only 1 run each).
```

GC "disabled", 10 runs:

```
msec task-clock:u: -5.0663% +/- 1.2758% (-586.83 +/- 147.78) (11583.04 -> 10996.20)
page-faults:u: -3.0945% +/- 0.0002% (-29796.30 +/- 1.81) (962877.60 -> 933081.30)
cycles:u: -5.5270% +/- 1.4680% (-2370772292.80 +/- 629706499.59) (42894735346.20 -> 40523963053.40)
instructions:u: -3.3051% +/- 0.0018% (-916691160.20 +/- 511613.60) (27735747067.70 -> 26819055907.50)
branch-misses:u: -5.8178% +/- 5.3891% (-5252006.40 +/- 4864978.91) (90275210.60 -> 85023204.20)
seconds time elapsed: -5.0598% +/- 1.2754% (-0.59 +/- 0.15) (11.59 -> 11.00)
seconds user: -5.6044% +/- 1.4672% (-0.56 +/- 0.15) (10.02 -> 9.46)
maxRssKbytes: -3.0862% +/- 0.0027% (-119263.20 +/- 103.41) (3864409.20 -> 3745146.00)
maxRssBytes: -3.0862% +/- 0.0027% (-122125516.80 +/- 105886.94) (3957155020.80 -> 3835029504.00)
```

The take-away - for me - is this:
On this compile there's executed about 916 mio instructions less and a reduction of "garbage" created of about 116 MB - all without GC.
With normal GC stuff also happens to the GC (e.g. because of the ~116 MB less "garbage" being created) and it makes the numbers different - in this case both instructions, cycles and time is in the 6-7% savings range (compared to the ~3% instructions saving without GC) - but how much of the extra 3-4 %-points is "real" (because of different GC etc) and how much is "artifact" is a question.


Runs of "pkg/analyzer/tool/stable_analysis.aot" with no extra arguments run on the golem version of the cfe

Normal GC, 10 runs:

```
msec task-clock:u: -1.4721% +/- 0.9488% (-172.44 +/- 111.13) (11713.69 -> 11541.25)
page-faults:u: 0.3663% +/- 0.1061% (706.10 +/- 204.49) (192778.20 -> 193484.30)
cycles:u: -1.5475% +/- 0.9836% (-764366372.80 +/- 485822682.09) (49393259712.10 -> 48628893339.30)
instructions:u: -2.0415% +/- 0.0042% (-1242276662.60 +/- 2581212.09) (60849746427.20 -> 59607469764.60)
seconds time elapsed: -1.4702% +/- 0.9494% (-0.17 +/- 0.11) (11.72 -> 11.55)
seconds user: -1.2812% +/- 1.0658% (-0.15 +/- 0.12) (11.34 -> 11.19)
seconds sys: -7.1783% +/- 7.0964% (-0.03 +/- 0.03) (0.38 -> 0.35)
maxRssKbytes: 0.3406% +/- 0.0199% (2104.00 +/- 123.03) (617689.60 -> 619793.60)
maxRssBytes: 0.3406% +/- 0.0199% (2154496.00 +/- 125986.42) (632514150.40 -> 634668646.40)

Comparing GC data:
Scavenge(   new space) goes from 196 to 192
MarkSweep(   promotion) goes from 16 to 18
MarkSweep(   old space) goes from 1 to 0
Notice combined GC time goes from 3588 ms to 3590 ms (notice only 1 run each).
```

GC "disabled", 10 runs:

```
msec task-clock:u: -3.2974% +/- 0.4563% (-731.49 +/- 101.23) (22184.14 -> 21452.64)
page-faults:u: -2.1323% +/- 0.0001% (-30583.00 +/- 1.74) (1434269.00 -> 1403686.00)
cycles:u: -3.4584% +/- 0.5315% (-2959866681.50 +/- 454870221.35) (85585124094.10 -> 82625257412.60)
instructions:u: -2.1807% +/- 0.0060% (-953640339.30 +/- 2623134.87) (43731091459.60 -> 42777451120.30)
seconds time elapsed: -3.2897% +/- 0.4559% (-0.73 +/- 0.10) (22.20 -> 21.47)
seconds user: -3.2631% +/- 0.6243% (-0.65 +/- 0.12) (19.88 -> 19.23)
seconds sys: -3.5965% +/- 3.3140% (-0.08 +/- 0.08) (2.31 -> 2.22)
maxRssKbytes: -2.1260% +/- 0.0017% (-122282.00 +/- 99.83) (5751738.80 -> 5629456.80)
maxRssBytes: -2.1260% +/- 0.0017% (-125216768.00 +/- 102222.23) (5889780531.20 -> 5764563763.20)
```

The take-away - for me - is this:
This shaves off about 953 mio instructions and ~119 MB of "garbage" without GC.
With normal GC stuff is pushed differently and the change looks smaller than before - about 1.5-2% instead.

Change-Id: I4dc8570717ac21c84b6645c33e78cee364823822
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/479900
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
4 files changed
tree: b2e7b5c013dd8abcdba0ec1defab56b2bbcfb4e2
  1. .dart_tool/
  2. .github/
  3. benchmarks/
  4. build/
  5. docs/
  6. pkg/
  7. runtime/
  8. samples/
  9. sdk/
  10. tests/
  11. third_party/
  12. tools/
  13. utils/
  14. .clang-format
  15. .gitattributes
  16. .gitconfig
  17. .gitignore
  18. .gn
  19. .mailmap
  20. .style.yapf
  21. AUTHORS
  22. BUILD.gn
  23. CHANGELOG.md
  24. codereview.settings
  25. CONTRIBUTING.md
  26. DEPS
  27. LICENSE
  28. OWNERS
  29. PATENT_GRANT
  30. PRESUBMIT.py
  31. pubspec.yaml
  32. README.dart-sdk
  33. README.md
  34. sdk.code-workspace
  35. sdk_args.gni
  36. sdk_packages.yaml
  37. SECURITY.md
  38. WATCHLISTS
README.md

Dart

An approachable, portable, and productive language for high-quality apps on any platform

Dart is:

  • Approachable: Develop with a strongly typed programming language that is consistent, concise, and offers modern language features like null safety and patterns.

  • Portable: Compile to ARM, x64, or RISC-V machine code for mobile, desktop, and backend. Compile to JavaScript or WebAssembly for the web.

  • Productive: Make changes iteratively: use hot reload to see the result instantly in your running app. Diagnose app issues using DevTools.

Dart's flexible compiler technology lets you run Dart code in different ways, depending on your target platform and goals:

  • Dart Native: For programs targeting devices (mobile, desktop, server, and more), Dart Native includes both a Dart VM with JIT (just-in-time) compilation and an AOT (ahead-of-time) compiler for producing machine code.

  • Dart Web: For programs targeting the web, Dart Web includes both a development time compiler (dartdevc) and a production time compiler (dart2js).

Dart platforms illustration

License & patents

Dart is free and open source.

See LICENSE and PATENT_GRANT.

Using Dart

Visit dart.dev to learn more about the language, tools, and to find codelabs.

Browse pub.dev for more packages and libraries contributed by the community and the Dart team.

Our API reference documentation is published at api.dart.dev, based on the stable release. (We also publish docs from our beta and dev channels, as well as from the primary development branch).

Building Dart

If you want to build Dart yourself, here is a guide to getting the source, preparing your machine to build the SDK, and building.

There are more documents in our repo at docs.

Contributing to Dart

The easiest way to contribute to Dart is to file issues.

You can also contribute patches, as described in Contributing.

Roadmap

Future plans for Dart are included in the combined Dart and Flutter roadmap on the Flutter wiki.