Commit Graph

30 Commits

Author SHA1 Message Date
Slava Egorov 488f97eb76 [vm] Update ObjectSlots to handle _LinkedHashBase
Generalize code which computes slots map to handle class hierarchies
which include base classes with VM-described layout like
_LinkedHashBase.

Fixes https://github.com/dart-lang/sdk/issues/63180

TEST=vm/dart/heap_snapshot_regress_63180

Change-Id: I32ab0e258e735f745d45f25813177d0f6a6a6964
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/496861
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Slava Egorov <vegorov@google.com>
2026-04-21 04:02:25 -07:00
Sigurd Meldgaard 2fe05bd568 Reland "Migrate to use pub workspace"
This is a reland of commit b9b77058a9

Original change's description:
> Migrate to use pub workspace
>
> Use `pub get` to generate `.dart_tool/package_config.json` on gclient sync.
>
> All pkg/ (and a few third_party) packages that are developed inside the sdk repo are included in the workspace from the root `pubspec.yaml`.
>
> All dependencies that are pulled in via DEPS are added as path dependencies via `dependency_overrides` in the root `pubspec.yaml`.
>
> Bug: https://github.com/dart-lang/sdk/issues/56220
> Change-Id: I38c12b608c68da54c57821116cf9aa6696936746
> Tested: relies on CQ of existing tests. Should have no effect on functionality
> CoreLibraryReviewExempt: only core library change is adding a `// ignore:` comment. Should have no influence on functionality
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/397164
> Commit-Queue: Sigurd Meldgaard <sigurdm@google.com>
> Reviewed-by: Alexander Thomas <athom@google.com>

Bug: https://github.com/dart-lang/sdk/issues/56220
Change-Id: I29afabade2d2447dea05121cb87ff50bb21a4b76
Cq-Include-Trybots: luci.dart.try:flutter-linux-try,flutter-web-try
Tested: relies on CQ of existing tests. Should have no effect on functionality
CoreLibraryReviewExempt: only core library change is adding a `//
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/415561
Commit-Queue: Sigurd Meldgaard <sigurdm@google.com>
Reviewed-by: Alexander Thomas <athom@google.com>
2025-03-20 06:19:16 -07:00
Sigurd Meldgaard 6c4de1ab7e Revert "Migrate to use pub workspace"
This reverts commit b9b77058a9.


Revert "Add missing sample pubspec to workspace"

This reverts commit 892ea15ac7.


These seem to break the engine.

Change-Id: Ieee26deb7928c3869a1b6265326c3ce568ffe731
Tested: this is a revert.
CoreLibraryReviewExempt: this is a revert
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/415582
Commit-Queue: Sigurd Meldgaard <sigurdm@google.com>
Reviewed-by: Alexander Thomas <athom@google.com>
2025-03-14 09:08:20 -07:00
Sigurd Meldgaard b9b77058a9 Migrate to use pub workspace
Use `pub get` to generate `.dart_tool/package_config.json` on gclient sync.

All pkg/ (and a few third_party) packages that are developed inside the sdk repo are included in the workspace from the root `pubspec.yaml`.

All dependencies that are pulled in via DEPS are added as path dependencies via `dependency_overrides` in the root `pubspec.yaml`.

Bug: https://github.com/dart-lang/sdk/issues/56220
Change-Id: I38c12b608c68da54c57821116cf9aa6696936746
Tested: relies on CQ of existing tests. Should have no effect on functionality
CoreLibraryReviewExempt: only core library change is adding a `// ignore:` comment. Should have no influence on functionality
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/397164
Commit-Queue: Sigurd Meldgaard <sigurdm@google.com>
Reviewed-by: Alexander Thomas <athom@google.com>
2025-03-14 05:21:40 -07:00
Sigurd Meldgaard a9ab52bcbb Language version bumps for publish_to: none pkgs
Also a separate pubspec for the tools/ folder

Extracted from https://dart-review.googlesource.com/c/sdk/+/397164

Change-Id: If49a6ede07e4864d0c0fcb210c04c18c804849df
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/412041
Commit-Queue: Sigurd Meldgaard <sigurdm@google.com>
Reviewed-by: Alexander Thomas <athom@google.com>
2025-02-27 00:48:40 -08:00
Martin Kustermann f3bce39727 [tools] Hide cursor while drawing prompt in heapsnapshot analysis tool to avoid flickering cursor
Change-Id: I544bfd16a1fc5f4bbb243d66d73526995037e9bc
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/388821
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
2024-10-08 08:24:12 +00:00
Vyacheslav Egorov d345fbadd4 [tools] Fix heapsnapshot console crashes
`Console.cursorPosition` can return null when you are typing too
fast because it is implemented by sending an escape code to
the terminal and reading what it responds. This response is
naturally intermingled with normal input and the implementation
does nothing to guard against that.

We do not really need to know the cursor position though
we are simply interested in keeping cursor on the same row.
But this can be achieved by sending _horizontal position absolute_
which only changes column rather than _cursor position_
which sets both row and column.

R=kustermann@google.com

TEST=manually tested

Change-Id: Ie1a064e37b90bc4529ac4f5c1259642ad5680ca6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/388340
Commit-Queue: Slava Egorov <vegorov@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2024-10-07 10:53:42 +00:00
Ben Konyi 12d9f40961 Reapply "[ CLI ] Don't disable DDS when --disable-dart-dev is provided"
This reverts commit 9f5246e8c6.

TEST=Existing tests

Change-Id: I658290f248d8b26c05f24b7125c3ba71de318bf9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/385121
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Ben Konyi <bkonyi@google.com>
2024-09-26 15:29:05 +00:00
Ben Konyi 9f5246e8c6 Revert "[ CLI ] Don't disable DDS when --disable-dart-dev is provided"
This reverts commit 81b9957bdd.

Reason for revert: Breaking multiple configurations.

Original change's description:
> [ CLI ] Don't disable DDS when --disable-dart-dev is provided
>
> Fixes https://github.com/dart-lang/sdk/issues/56605
> Fixes https://github.com/dart-lang/sdk/issues/54841
>
> TEST=N/A
>
> Change-Id: I6a13afe5f51fe67d2366c6d87ae74473651e24c8
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/383780
> Commit-Queue: Ben Konyi <bkonyi@google.com>
> Auto-Submit: Ben Konyi <bkonyi@google.com>
> Reviewed-by: Johnni Winther <johnniwinther@google.com>
> Reviewed-by: Phil Quitslund <pquitslund@google.com>

Change-Id: I5c6cb302d8160f19bad437341cdcd80bcc08d921
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/384881
Reviewed-by: Siva Annamalai <asiva@google.com>
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Reviewed-by: Derek Xu <derekx@google.com>
Auto-Submit: Ben Konyi <bkonyi@google.com>
Commit-Queue: Siva Annamalai <asiva@google.com>
2024-09-12 01:15:27 +00:00
Ben Konyi 81b9957bdd [ CLI ] Don't disable DDS when --disable-dart-dev is provided
Fixes https://github.com/dart-lang/sdk/issues/56605
Fixes https://github.com/dart-lang/sdk/issues/54841

TEST=N/A

Change-Id: I6a13afe5f51fe67d2366c6d87ae74473651e24c8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/383780
Commit-Queue: Ben Konyi <bkonyi@google.com>
Auto-Submit: Ben Konyi <bkonyi@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Phil Quitslund <pquitslund@google.com>
2024-09-11 18:01:25 +00:00
Konstantin Shcheglov b7d3c47d13 Adds benchmark measuring memory consumption of live objects after analyzing flutter.
Will warm up the memory cache and then measure how much live memory the analyzer consumes after visiting all elements with the warmed up cache.

All results
--------------------------------
flutter_elements
  reachableObjects
    count: 9071480
    size: 799672175 = 780929 KB = 762 MB
  _SimpleUri
    count: 3112
    size(shallow): 248960 = 243 KB
    duplicateCount: 0

Change-Id: I75209f88f6f615172127cd439afe9d0cd83b1c4f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/329682
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2023-10-10 17:54:08 +00:00
Jens Johansen c49f87382b [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>
2023-09-11 10:48:46 +00:00
Polina Cherkasova 4de8a314c4 Update README.md
Closes https://github.com/dart-lang/sdk/pull/52114

GitOrigin-RevId: 1a0abe31e57c60bfeaf5bc857a08b0f6bc3986d2
Change-Id: I837ff4f5fdf9afdbd2cbce3073f87e51a62960c0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/296701
Commit-Queue: Polina Cherkasova <polinach@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2023-04-25 18:50:20 +00:00
Martin Kustermann e1c2192110 [vm] Make writeHeapSnapshotToFile() API public in dart:developer
This API can be used by app developers that want to diagnose high
memory consumption by dumping state of Dart VM heap at specific
points in their apps code and later analyzing those dumps offline
(e.g. using the tool in `<sdk>/runtime/tools/heapsnapshot`).

TEST=Existing test suite.

Change-Id: I04de6ba564f7b9eaf8b59d41fc4b3ec35ce8d2e5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/279972
Reviewed-by: Aske Simon Christensen <askesc@google.com>
Reviewed-by: Michael Thomsen <mit@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Reviewed-by: Lasse Nielsen <lrn@google.com>
Reviewed-by: Jacob Richman <jacobr@google.com>
Reviewed-by: Siva Annamalai <asiva@google.com>
2023-04-03 12:25:55 +00:00
Konstantin Shcheglov 895540889e Update SDK constraints for SDK packages.
https://dart-review.googlesource.com/c/sdk/+/287660 implements it.
I want to fix pre-existing violations before enabling.

Bug: https://github.com/dart-lang/sdk/issues/34978
Change-Id: Ie7731162c643018a2312b265f444bc00534c0a51
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/287664
Reviewed-by: Leon Senft <leonsenft@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Ben Konyi <bkonyi@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2023-03-09 19:52:47 +00:00
Martin Kustermann d71a37af18 Support external typed data in heapsnapshot analysis tool
TEST=runtime/tools/heapsnapshot/test/cli_test.dart

Change-Id: I684bfb344f079d9d29bc910b5f2fdda99257821e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/284303
Reviewed-by: Tess Strickland <sstrickl@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
2023-02-21 12:58:34 +00:00
Josh Soref f7a2ea5e06 Spelling
Closes https://github.com/dart-lang/sdk/pull/50922

GitOrigin-RevId: 58fd7cfd5ef470a65a52ea28e0407244d853c917
Change-Id: I2e5a5ed991cb05270170a18b8f0169daa9eabdb7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/278537
Reviewed-by: Alexander Thomas <athom@google.com>
Commit-Queue: Alexander Thomas <athom@google.com>
2023-01-24 18:00:25 +00:00
Martin Kustermann 2ffbc88fc6 Make package:heapsnapshot prefer to mmap files over reading them.
Change-Id: I23de18aac05beae8005e471335b72a2ed22d1eb5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/279349
Reviewed-by: Jens Johansen <jensj@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
2023-01-23 10:22:41 +00:00
Martin Kustermann 8d8782f659 Make runtime/tools/heapsnapshot/README.md more elaborate
Change-Id: I8ee4952d3889b8eec10495f900d26be1e3f7c34e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/279354
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
2023-01-19 13:12:02 +00:00
Jens Johansen dde72f78a2 [vm] Heap snapshot tool can load file from arguments
This CL allows the heap snapshot tool to load a file as it is launched
via a command like
```
../../../out/ReleaseX64/dart bin/explore.dart my_snapshot.heapsnapshot
```

Change-Id: I4eca4ec18daef4d3361c754018d234045e725ef5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/275860
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2022-12-15 12:31:45 +00:00
Jens Johansen 93ef21b00b [vm] Add examples to heapsnapshot tool
Change-Id: I2b3735341146e532a747e302050e3983ee8f7e1c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/273240
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
2022-12-05 15:02:27 +00:00
Jens Johansen b0ca324b08 [VM] Fix crash on >num filter in heapsnapshot tool
Change-Id: I873d98452e88d2b55b485cc14daa1823af2ba0f2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/273741
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2022-12-05 14:49:50 +00:00
Jens Johansen 89b6ba91ba [vm] tools/heapsnapshot has download util
Change-Id: I11e8a750a3a40d3fbc2733f4120c50b25194cc82
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/273183
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
2022-12-01 13:25:47 +00:00
Ryan Macnak 9a5dd4707f [vm] Remove "Impl" suffix from VM implementation classes.
This makes things nicer to read in places that display implementation names, such as stack traces, debuggers, profilers and inspectors.

TEST=ci
Change-Id: I959f70d9e51be59801c4455f8c5ccac3c214c21a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/270502
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Daco Harkes <dacoharkes@google.com>
2022-11-18 21:42:59 +00:00
Ryan Macnak a2de36e708 [vm] Rename the default implementation classes of Map and Set.
_InternalLinkedHashMap => _Map
_InternalImmutableLinkedHashMap => _ConstMap
_InternalLinkedHashSet => _Set
_InternalImmutableLinkedHashSet => _ConstSet

This makes things nicer to read in places that display implementation names, such as stack traces, debuggers, profilers and inspectors.

TEST=ci
Change-Id: Iec851c80ea2086cbe79934565dbf35f04809a836
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/266303
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
2022-11-15 17:15:58 +00:00
Ryan Macnak 2d6037a144 [vm, service] Include Smis in heap snapshots.
TEST=ci
Change-Id: Iadb3bb749da0d065c46bc723c7f5a8a8951b68bd
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/265562
Reviewed-by: Ben Konyi <bkonyi@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2022-10-26 16:04:29 +00:00
Martin Kustermann 2932261f83 Allow tab-completion of exit/quit/help
TEST=runtime/tools/heapsnapshot/test/completion_test.dart

Change-Id: Ia3bffbdf2b115d15ad90c8cc68870af19e3c373e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/261822
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Tess Strickland <sstrickl@google.com>
2022-10-04 12:31:45 +00:00
Martin Kustermann 756379442e Abstract out the used set implementation in heapsnapshot analysis tool.
Doing so will allow using a more efficient (both memory-wise
and perf-wise) set implementation.

TEST=ci

Change-Id: Ia64ad5785bab6dba668c5fc3e2dcfcaf482d8b83
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/262424
Commit-Queue: Tess Strickland <sstrickl@google.com>
Reviewed-by: Tess Strickland <sstrickl@google.com>
2022-10-04 09:58:19 +00:00
Martin Kustermann aa4339a9f3 Allow tab-completion of commands, expression types and named sets
This CL extends the heapsnapshot analysis CLI with tab-completion support
for commands, options, filenames, expression types and named sets.

This makes it much more comfortable to use the tool.

TEST=runtime/tools/heapsnapshot/test/completion_test

Change-Id: Iea48b4bd12651a60add6206a92ce06823cbd754a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/262243
Reviewed-by: Tess Strickland <sstrickl@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
2022-10-03 14:58:58 +00:00
Martin Kustermann ed5ad5c087 Add CLI tool for analyzing Dart VM heapsnapshots
This CL adds an interactive command line tool to analyze
heapsnapshots generated by the Dart VM.

The tool works by operating on sets of objects. It supports operations
like users, transitive closure, union, ...

An example usage that loads snapshot, finds all live objects, finds
the empty lists in them and prints retainers of the empty lists:

    ```
    % dart bin/explore.dart

    (hsa) load foo.heapsnapshot

    (hsa) all = closure roots
    (hsa) stat all
          size       count     class
      --------   --------  --------
       43861 kb    8371    _Uint8List dart:typed_data
         ...
      --------   --------  --------
      108904 kb  400745

    (hsa) empty-lists = dfilter (filter all _List) ==0
    (hsa) empty-growable-lists = filter (users empty-lists) _GrowableList

    (hsa) retain empty-growable-lists
    There are 5632 retaining paths of
    _GrowableList (dart:core)
    ⮑ ・UnlinkedLibraryImportDirective.configurations (package:analyzer/src/dart/analysis/unlinked_data.dart)
        ⮑ ﹢_List (dart:core)
            ⮑ ・...
    ```

For now the tool lives only in dart-lang/sdk.

TEST=pkg/heapsnapshot/test/*_test.dart

Change-Id: I671c2e3ca770e1a5aa3e590e850a5694070b4c3a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/261100
Reviewed-by: Tess Strickland <sstrickl@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
2022-09-30 14:15:01 +00:00