dart-sdk/pkg/kernel
Jens Johansen 60183d0dc4 [ddc/testing/cfe/kernel] Wire up leak testing in ddc batch testing; fix 'semi-leaks'
There's been some talks about weird failures on DDC and there was
ideas that this was caused by some sort of leak (of kernel libraries).

I haven't really found any "meaningful" leaks that should be able
to cause that.

What I have found is this:

* a temporary leak where the vm seemingly gets "one behind".
  That's fixed here by creating a class for the ddc batch compiler,
  having things in field variables etc. It shouldn't influence results.
* a leaks via https://github.com/dart-lang/sdk/issues/51317 --- but
  that's just wasted memory, I can't see how that should influence
  results.
* a leak via kernels dummy nodes --- again it shouldn't influence
  results (unless we're leaving dummy nodes in the output somewhere
  --- which, considering I'm removing that in my test by null'ing out
  the parent pointer and stuff still working I'm guessing we're not).
* another leak via some ports map after a crash, but that seems
  to go away on its own (the VM cleaning it up later than I think it
  should?). Again it shouldn't influence anything other than
  (temporary) wasted space.

I've wired up the leak testing stuff into the DDC batch mode so that
one can go into "leak test mode" by doing `export DDC_LEAK_TEST="true"`
on the terminal (I think `set DDC_LEAK_TEST="true"` on Windows).
Then one could run test.py, say

```
python3 tools/test.py -t10000 -c dartdevk --nnbd weak -m release \
  -r none --enable-asserts --no-use-sdk -j 1 co19/LanguageFeatures/
```

and attach the leak tester via

```
out/ReleaseX64/dart \
  pkg/front_end/test/vm_service_for_leak_detection.dart --dart-leak-test
```

Currently this finds - if I recall correctly - 3 leaks (I think all via
the ports map stuff), but it all goes away again on it's own, so likely
another case of the VM somehow getting "one behind".

Change-Id: Idbf057e3aedfe7b256370f90ddf72f1f8e6798a8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/282027
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Nicholas Shahan <nshahan@google.com>
2023-02-10 08:29:37 +00:00
..
bin
doc
lib
test
tool
.gitignore
analysis_options.yaml
AUTHORS
binary.md
codereview.settings
LICENSE
OWNERS
PRESUBMIT.py
problems.md
pubspec.yaml
README.md

Dart Kernel

Dart Kernel is a small high-level language derived from Dart. It is designed for use as an intermediate format for whole-program analysis and transformations, and to be consumed by codegen and execution backends.

The kernel language has an in-memory representation in Dart and can be serialized as binary or text.

Both the kernel language and its implementations are unstable and are under development.

This package contains the Dart part of the implementation and contains:

  • A transformable IR for the kernel language
  • Serialization of kernel code

Note: The APIs in this package are in an early state; developers should be careful about depending on this package. In particular, there is no semver contract for release versions of this package. Please depend directly on individual versions.

See ast.dart for the in-memory IR, or binary.md for a description of the binary format. For now, the textual format is very ad-hoc and cannot be parsed back in.