Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TFA does not recognize List.from(l, growable: false) and l.toList(growable: false) #47509

Closed
mraleph opened this issue Oct 20, 2021 · 0 comments
Labels
area-vm Use area-vm for VM related issues, including code coverage, and the AOT and JIT backends. type-performance Issue relates to performance or code size vm-aot-code-size Related to improvements in AOT code size

Comments

@mraleph
Copy link
Member

mraleph commented Oct 20, 2021

When trying to create a test case where TFA would infer that something is a fixed length list I have noticed that TFA does not recognize either of these patterns as producing a fixed-length list. (even when l is a list literal).

/cc @alexmarkov

@mraleph mraleph added area-vm Use area-vm for VM related issues, including code coverage, and the AOT and JIT backends. type-performance Issue relates to performance or code size vm-aot-code-size Related to improvements in AOT code size labels Oct 20, 2021
copybara-service bot pushed a commit that referenced this issue May 22, 2023
This change improves type flow analysis by adding conditional data
flow. Now each statement in the data flow summary can have an optional
condition. If a condition is present, then the statement is applied
only if its condition is not a 'false' constant. The condition may
become false as a result of whole-program type and constant
propagation (constant value is an optional property of a concrete
type).

Conditions in the data flow summary are populated from conditions in
the 'if' statements and conditional expressions. Conditions are
propagated down the control flow while building the summary.
For example:

  if (x) { return foo(); }
  bar();

Call 'foo()' is guarded by condition 'x' and 'bar()' is guarded by
condition '!x'.

Also, a bunch of unary and binary operations are added in order to
represent logical expressions, comparisons with null, 'is' tests and
conditional moves.

This change makes TFA much more sensitive to the control flow.

In order to offset increase in the compilation time due to the
additional condition and operations in the data flow summary,
the following is done:
* Types corresponding to bool constants are canonicalized; condition
  checking and logical operations are performed using fast identical
  checks.
* Fast identical checks are also added to union and intersection of
  types.
* Added more sophisticated simplifications of Join statements.

Along with reduced analysis due to skipped data flow statements with
false conditions, these improvements result in the slightly reduced
compilation time.

AOT compilation time on large Flutter apps (only AOT step 2 / TFA):
App 1: Before: 65.448s After: 62.893s (-3.9%)
App 2: Before: 55.067s After: 52.192s (-5.2%)

AOT snapshot size of large Flutter apps (Flutter release mode, arm64):
App 1: Before: 32910316 After: 32599936 (-0.9%)
App 2: Before: 34464544 After: 34092907 (-1.0%)
Flutter gallery: -1.9%

Performance on micro-benchmark from #51630 in AOT mode:
Before: 0.405839
After: 0.172886 (2.3x faster than before, still slower than JIT)

TEST=pkg/vm/testcases/transformations/type_flow/transformer/regress_47509.dart
TEST=pkg/vm/testcases/transformations/type_flow/transformer/regress_51630.dart

Issue: #51630
Fixes #48154
Fixes #47509

Change-Id: I29baf2933972adf83fd58be5ec25be8c30665c01
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/300700
Reviewed-by: Martin Kustermann <kustermann@google.com>
Reviewed-by: Ömer Ağacan <omersa@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-vm Use area-vm for VM related issues, including code coverage, and the AOT and JIT backends. type-performance Issue relates to performance or code size vm-aot-code-size Related to improvements in AOT code size
Projects
None yet
Development

No branches or pull requests

2 participants