This optimization is based on the assumption (which at least holds true for the dill file extracted from the mentioned bug) that only very few nodes actually have metadata associated with it. For the test file, more than two million node-offsets is looked up, and only ~7.5 thousand nodes actually have metadata on it. What is done here is to assume that most often we ask offsets in order and that most often the answer is that there's no metadata (when we fall into this case we can return `false` quickly) and we can skip looking up the actual metadata. This furthermore - although not benchmark here - should make it (a lot) faster in the case where we have multiple subsections as we here only lookup in in one index. Only upon a `true` response from that we have to lookup in all subsections to find and read the actual metadata to associate. Reading the test file without metadata, taking an average of averages (average of 5 runs of the binary benchmarks output for "AstFromBinaryEager") takes: 374481.4 us. Before https://dart-review.googlesource.com/c/sdk/+/391761 reading the test file with metadata takes: 627120.68 us. This was about a quarter of a second, or 67+% slower. With https://dart-review.googlesource.com/c/sdk/+/391761 this number became: 441784.44 us. A reduction of ~185 ms, or almost 30%, making the tax of reading metadata "only" ~18%. With this CL this number goes to 398011.44 us. This is a further reduction of ~43 ms, or almost 10% (for a combined reduction of ~230 ms or 36+%). The tax of reading metadata is now ~6.3%. Bug: https://github.com/flutter/flutter/issues/156713 Change-Id: I20bbabecfc8976293fe897528d05fc2145e2a8c0 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/392021 Reviewed-by: Johnni Winther <johnniwinther@google.com> Commit-Queue: Jens Johansen <jensj@google.com>
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.