[analyzer] Fix signature calculation when merging yaml files with "error" keys

**TL;DR**
In certain situations a new signature was created for every
analyzer start causing more work than needed to be done and filling up
the cache for no reason. The fix can cause the startup cost to improve
significantly.

**Details**
When merging analysis options yaml files (when one file includes
another), and both include data under "analyzer: errors:" we get
inconsistent signatures because of ordering issues. This causes "old
work" to be redone and more files to be written.

This CL fixes the issue by not introducing a semi-random order when
merging.

For the contexts I have open, the following files gives (gave) a bad
(inconsistent) signature:
pkg/analyzer/test/analysis_options.yaml
pkg/front_end/analysis_options.yaml
pkg/analysis_server/test/analysis_options.yaml

Looking at the time it takes from the first read/write until the last:
Before:
37.148419
37.273016
36.807384

Now:
14.164655
15.251373
15.108677

While the difference is easily visible, for good measure:

```
Difference at 95.0% confidence
        -22.2347 +/- 1.0223
        -59.9702% +/- 2.7573%
        (Student's t, pooled s = 0.45103)
```

And from the column "time" in top (note that I'm running from source so
that this includes the initial dart compile of the analyzer):
Before:
1:10.84
1:09.81
1:26.98

Now:
0:38.03
0:38.72
0:37.79

Again the difference is easily visible, but for good measure:

```
Difference at 95.0% confidence
        -37.6967 +/- 15.4529
        -49.6815% +/- 20.3658%
        (Student's t, pooled s = 6.81767)
```

If clearing the cache and opening (waiting for writes to complete),
closing and repeating, before this CL I got this with the contexts I
have open:

After 1st open:
```
$ du -chs ~/.dartServer/
186M    total
```

After the 2nd open:
```
$ du -chs ~/.dartServer/
212M    total
```

 => +26MB

After the 3rd open:
```
$ du -chs ~/.dartServer/
247M    total
$ find ~/.dartServer/ | wc -l
25713
```

 => +35MB

After the 4th open:
```
$ du -chs ~/.dartServer/
272M    total
$ find ~/.dartServer/ | wc -l
27769
```

 => +25MB; +2056 files

After the 5th open:
```
$ du -chs ~/.dartServer/
297M    total
$ find ~/.dartServer/ | wc -l
29825
```

 => +25MB; +2056 files

After the 6th open:
```
$ du -chs ~/.dartServer/
321M    total
$ find ~/.dartServer/ | wc -l
31881
```

 => +24MB; +2056 files

And we seem to have reached a point where we can guess the 7th if we want to.

And with the fix in this CL:

After 1st open:
```
$ du -chs ~/.dartServer/
186M    total
$ find ~/.dartServer/ | wc -l
20816
```

After 2nd:
```
$ du -chs ~/.dartServer/
186M    total
$ find ~/.dartServer/ | wc -l
20816
```

After the 3rd:
```
$ du -chs ~/.dartServer/
186M    total
$ find ~/.dartServer/ | wc -l
20816
```

And it seems that it's stable.

We might also want to sort the strings as ordering (probably?) doesn't
matter, but I'll leave that for another CL.

Change-Id: Id06ca84e8b063bb31a261753f56620443f341a2e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/410700
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
3 files changed
tree: b026996f5fa1855a0678ad9d8229255515d1c119
  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. README.dart-sdk
  32. README.md
  33. sdk.code-workspace
  34. sdk_args.gni
  35. sdk_packages.yaml
  36. SECURITY.md
  37. 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.