[vm] Use specialized int set in heap snapshot tool

Currently the heap snapshot tool uses a regular Set<int> for storing
ints between 0 and the number of objects (n).

This CL instead introduces a specialized int set backed by a Uint8List
where each bit represents a number between 0 and n.

This specialized set is then created to fit the number of objects, so
even an empty set takes the same amount of space as a full set: about
125 kb per million possible values (or ~6 mb per 50 million).

For small sets thats a lot worse than before, but for big sets it's a
lot better. Runtime is also a lot better.

"Benchmarks" on a snapshot that's ~1.5GB:

Runtimes:

Before:
closure roots (or all after the first one): ~30s, ~19s, ~20s
eval and: ~5.5s, ~6.3, ~5.6
eval or: ~7.3s, ~6.5s, ~6.4s
eval minus: ~4.5s, ~6.4s, ~6.5s

With CL:
closure roots (or all after the first one): ~7.7s, ~4.3s, ~4.1s
eval and: ~0.2s, ~0.3s, ~0.2s
eval or: ~0.6s, ~0.6s, ~0.6s
eval minus: ~0.3s, ~0.2s, ~0.3s


Memory usage:

Before:

after loaded:
$ grep -E "VmPeak|VmSize|VmRSS" /proc/588700/status
VmPeak: 10293036 kB
VmSize:  9896880 kB
VmRSS:   9260604 kB

after all = closure roots
VmPeak: 12354840 kB
VmSize:  9529612 kB
VmRSS:   8898088 kB

after 2 x closure all
VmPeak: 13068580 kB
VmSize: 12478236 kB
VmRSS:  11891620 kB

after 3 x eval and
VmPeak: 18377540 kB
VmSize: 18376520 kB
VmRSS:  17803032 kB

after 3 x eval or
VmPeak: 19621712 kB
VmSize: 18114376 kB
VmRSS:  17491808 kB

after 3 x eval minus
VmPeak: 21522780 kB
VmSize: 21522272 kB
VmRSS:  20907724 kB


With CL:

after loaded:
$ grep -E "VmPeak|VmSize|VmRSS" /proc/594718/status
VmPeak: 10293560 kB
VmSize:  9967036 kB
VmRSS:   9323404 kB

after all = closure roots
VmPeak: 10293560 kB
VmSize:  9805272 kB
VmRSS:   9137364 kB

after 2 x closure all
VmPeak: 10868740 kB
VmSize: 10867208 kB
VmRSS:  10199784 kB

after 3 x eval and
VmPeak: 10906236 kB
VmSize: 10905728 kB
VmRSS:  10238424 kB

after 3 x eval or
VmPeak: 10925496 kB
VmSize: 10924988 kB
VmRSS:  10257388 kB

after 3 x eval minus

VmPeak: 10944756 kB
VmSize: 10944248 kB
VmRSS:  10276672 kB
Change-Id: I8d0b65fa51ac2bd4696c4d2782c4423966a7fbae
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/324682
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
6 files changed
tree: cf409419b33ffbefa4c4254cdb39404ca6f55426
  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. .vpython
  22. AUTHORS
  23. BUILD.gn
  24. CHANGELOG.md
  25. codereview.settings
  26. CONTRIBUTING.md
  27. DEPS
  28. LICENSE
  29. OWNERS
  30. PATENT_GRANT
  31. PRESUBMIT.py
  32. README.dart-sdk
  33. README.md
  34. sdk.code-workspace
  35. sdk_args.gni
  36. SECURITY.md
  37. WATCHLISTS
README.md

Dart

A client-optimized language for fast apps on any platform

Dart is:

  • Optimized for UI: Develop with a programming language specialized around the needs of user interface creation.

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

  • Fast on all platforms: Compile to ARM & x64 machine code for mobile, desktop, and backend. Or compile to JavaScript for the web.

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 on our wiki.

Contributing to Dart

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

You can also contribute patches, as described in Contributing.