Introduces Dart_NewFinalizableHandle which does auto delete itself,
but does not allow accessing the weak referenced object.
Issue: https://github.com/dart-lang/sdk/issues/42312
Change-Id: I24ea732925122c453213c4fa3f629761c352f838
Cq-Include-Trybots:dart/try:vm-ffi-android-debug-arm-try,vm-ffi-android-debug-arm64-try,app-kernel-linux-debug-x64-try,vm-kernel-linux-debug-ia32-try,vm-kernel-win-debug-x64-try,vm-kernel-win-debug-ia32-try,vm-kernel-precomp-linux-debug-x64-try,vm-dartkb-linux-release-x64-abi-try,vm-kernel-precomp-android-release-arm64-try,vm-kernel-asan-linux-release-x64-try,vm-kernel-msan-linux-release-x64-try,vm-kernel-precomp-msan-linux-release-x64-try,vm-kernel-linux-release-simarm-try,vm-kernel-linux-release-simarm64-try,vm-kernel-precomp-android-release-arm_x64-try,vm-kernel-precomp-obfuscate-linux-release-x64-try,dart-sdk-linux-try,analyzer-analysis-server-linux-try,analyzer-linux-release-try,front-end-linux-release-x64-try,vm-kernel-precomp-win-release-x64-try,vm-kernel-mac-debug-x64-try,vm-precomp-ffi-qemu-linux-release-arm-try,vm-kernel-nnbd-linux-debug-x64-try,analyzer-nnbd-linux-release-try,front-end-nnbd-linux-release-x64-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/154695
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
A few people have expressed confusion about why the top-level size shown in the heap snapshot view does not correspond to the total in the allocation table view. The missing size is now shown.
Change-Id: Idc7e53cb6098263f9809d4bb7c3154a97c4ba3e8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/152408
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Ben Konyi <bkonyi@google.com>
This reverts commit 65e3c9d3b1.
Reason for revert: package:logging, package:stack_trace and package:usage need to be migrated first.
Original change's description:
> [vm, service, observatory] Bang Bang (My Type System Shot Me Down).
>
> Port the service tests and Observatory to Dart 3.
>
> Changes from the original landing:
>
> - The old tests are copied to observatory_2 / service_2 so the service can still be tested when running a legacy mode program
> - The test harness is taught about 'service_2'
> - Observatory's package is added to front end's opt-in list
> - Fixed some places in the bot configuration matrix so ensure 'service' runs on legacy bots and 'service_2' on weak-mode bots
>
> The ported tests themselves are not changed.
>
> Change-Id: I1d7e5cc61cdc044e1985e851bea7fd8a18f7d810
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/149720
> Commit-Queue: Ryan Macnak <rmacnak@google.com>
> Reviewed-by: Ben Konyi <bkonyi@google.com>
TBR=bkonyi@google.com,rmacnak@google.com
Change-Id: I43b72f149d8d7e9fe06006cdd8593fed1726aa3a
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/152004
Reviewed-by: David Morgan <davidmorgan@google.com>
Commit-Queue: David Morgan <davidmorgan@google.com>
Port the service tests and Observatory to Dart 3.
Changes from the original landing:
- The old tests are copied to observatory_2 / service_2 so the service can still be tested when running a legacy mode program
- The test harness is taught about 'service_2'
- Observatory's package is added to front end's opt-in list
- Fixed some places in the bot configuration matrix so ensure 'service' runs on legacy bots and 'service_2' on weak-mode bots
The ported tests themselves are not changed.
Change-Id: I1d7e5cc61cdc044e1985e851bea7fd8a18f7d810
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/149720
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Ben Konyi <bkonyi@google.com>
- Clean up loading flow.
- Replace manual iterators with generator functions.
- Produce clearer messages when running out of memory.
- Make various implementation functions and constants private.
Change-Id: I9e016b37552e3110baf00f3052b131dc0d79b748
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/132027
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Ben Konyi <bkonyi@google.com>
Don't flatten snapshot chunks into a linear byte array to avoid a 2GB limit in JS. The lifts the largest snapshot we can handle to either 2^32 objects or the memory limit in JS.
Change-Id: I1a3ec03cf83cb03b4cf67245b12560a083a6e5b6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/131943
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Ben Konyi <bkonyi@google.com>
In some workloads, the heap is mostly large pages.
Move large executable pages from the large list to the executable list. They do not require special treatment because they are large during sweeping because we never truncate an Instructions object. They still require being swept immediately because they are executable so that code protections can be flipped before resuming Dart execution.
Fix off-by-one errors in SnapshotGraph.objects and SnapshotClass.instances discovered as a result of the large page list changing from prepending to appending.
Bug: https://github.com/flutter/flutter/issues/48360
Change-Id: If6d9137fd36c9b18205493166d586b9a7cee4b1c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/130823
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Siva Annamalai <asiva@google.com>
This improves the time to deserialize a snapshot. It also doubles the memory needed to receive the snapshot buffer, but the memory high water mark is still computing the dominators.
Change-Id: Ib93015cd6cb366dd2ff750da09ddaa3b37159f68
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/115010
Reviewed-by: Ben Konyi <bkonyi@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
This replaces _requestHeapSnapshot and _getObjectByAddresses, which relied on the invalid assumption that objects don't move and the heap hasn't mutated since the initial snapshot.
Updates Observatory to the new format. Adds treemap visualization of the dominator tree. Adds the ability to save and load heap snapshots to files. Removes analysis grouping references by source and target class. Removes ability to navigate from a pixel in the fragmentation view to inspector. Removes ability to query the top retaining instance from an ordinary class browser.
Change-Id: Ia7781c05d43bf3ec149f8b4ecab803b37c3ee981
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/112181
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Ben Konyi <bkonyi@google.com>
When clicking the "toplist by retained memory" button in Observatory
it always asks to find 10 objects of a specific size.
The previous implementation did this by taking all objects (millions if
using a lot of memory), sorting it (O(n log n)), filtering it (O(n)),
and ".take"ing the 10 we wanted. Total runtime should be O(n log n)
where n is the number of objects in the heap.
This CL optimizes this for the (to my knowledge) only case there exists,
and instead, while iterationg over all elements (O(n)) keeps a sorted
working list of the top m objects (this is 10 for all intents and purpose
as far as I can see; I've if-cased it to be at most 20). Total runtime
should be O(n log m) where n is the number of objects in the heap and m
is the requested number, which - as said - is at most 20, i.e. a constant,
maying that the runtime is more like O(n).
Instrumenting the code slightly to measure how long it takes:
```
diff --git a/runtime/observatory/lib/src/repositories/top_retaining_instances.dart b/runtime/observatory/lib/src/repositories/top_retaining_instances.dart
index 400ac1427ed..b7e5c429fac 100644
--- a/runtime/observatory/lib/src/repositories/top_retaining_instances.dart
+++ b/runtime/observatory/lib/src/repositories/top_retaining_instances.dart
@@ -7,6 +7,8 @@ part of repositories;
class TopRetainingInstancesRepository
implements M.TopRetainingInstancesRepository {
Future<Iterable<M.RetainingObject>> get(M.IsolateRef i, M.ClassRef c) async {
+ Stopwatch stopwatch = new Stopwatch()..start();
+ try {
S.Isolate isolate = i as S.Isolate;
S.Class cls = c as S.Class;
assert(isolate != null);
@@ -18,5 +20,9 @@ class TopRetainingInstancesRepository
return (await Future.wait(
snapshot.getMostRetained(isolate, classId: cls.vmCid, limit: 10)))
.map((object) => new S.RetainingObject(object));
+ } finally {
+ int ms = stopwatch.elapsedMilliseconds;
+ print("TopRetainingInstancesRepository took $ms ms.");
+ }
}
}
```
I ran this program:
```
import "dart:isolate";
List<Object> data = [];
main() {
RawReceivePort preventClose = new RawReceivePort();
for(int i = 0; i < 10000000; i++) {
data.add(new List<int>()..add(i));
}
for(int i = 0; i < 100000; i++) {
data.add(new Foo(i));
}
}
class Foo {
final int i;
Foo(this.i);
}
```
and requested the toplist by retained memory for class `Foo`.
What before took 121778 ms now takes 81026 ms.
(For smaller numbers in the same test it went from ~10 seconds to ~8 seconds).
Change-Id: I6aee4b0c91af8a9ade116b79e56d1e6cbbee5d09
Reviewed-on: https://dart-review.googlesource.com/70502
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
Prior to this fix I get errors like
```
TypeError: Instance of 'b2<bQ>': type 'b2<bQ>' is not a subtype of type 'List<bQ>'
StackTrace:
main.dart.js 1631:3 Object.m
main.dart.js 2001:9 Object.p
[...]
```
Change-Id: I2fc6329c05cb76bff76929aeee1eca3954fbc0a9
Reviewed-on: https://dart-review.googlesource.com/70501
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
- Fix crash related to missing nodes in Heap Snapshot
- Disabled update on GC. With the new idle GC the page was updating too
often.
Change-Id: I8a3aaf9540ff224a5e8119303c8e8ef79e8a73f1
Reviewed-on: https://dart-review.googlesource.com/5327
Commit-Queue: Carlo Bernaschina <cbernaschina@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
An object A is said to be owned by object B if all direct references to A come from B. In particular, an object that holds unshared lists and maps will own the heap size of those lists and maps, as well as any unshared elements. We hope a table of owned sizes will be more useful than a table of shallow sizes, since the latter typically says the heap is mostly lists.
R=cbernaschina@google.com
Review-Url: https://codereview.chromium.org/3009743003 .
Fix observatory tests broken by running dartfmt due to line and column changes.
Temporarily reverted formatting for evaluate_activation_test.dart as dartfmt doesn't yet handle multitests.
BUG=
R=johnmccutchan@google.com
Review-Url: https://codereview.chromium.org/2759973004 .
I've omitted files where the formatter output is significantly uglier
than the original code and I'll send those files in a separate CL
with options for how to make the code look reasonable while still
taking advantage of the formatter.
BUG=
R=johnmccutchan@google.com
Review-Url: https://codereview.chromium.org/2751423005 .
[1] has worse upper bound complexity than [2] but has lower
overhead. With [1] dart2js heaps would converge in ~10 iterations, but
with analyzer heaps would take ~10k iterations.
This reduces the time to analyze the final heap of the analyzer
analyzing dart2js from ~30 minutes to 26 seconds.
Increases peak memory usage by 21N bytes plus O(2N) words.
[1] "A Simple, Fast Dominance Algorithm." Keith D. Cooper, Timothy
J. Harvey, and Ken Kennedy.
[2] "A Fast Algorithm for Finding Dominators in a Flowgraph."
T. Lengauer and R. E. Tarjan.
R=johnmccutchan@google.com
Review URL: https://codereview.chromium.org/1449243002 .