| commit | 06402ab1ca284cfd394a8bfb7fddbcbe242fc86e | [log] [tgz] |
|---|---|---|
| author | Jens Johansen <jensj@google.com> | Wed Jul 30 07:05:12 2025 -0700 |
| committer | Commit Queue <dart-scoped@luci-project-accounts.iam.gserviceaccount.com> | Wed Jul 30 07:05:12 2025 -0700 |
| tree | 7393f1ba5f7daa4e9db17b0f67ec4cf8ac7970fb | |
| parent | 9c5eea2b1af09ded9c9ab0d7aaa8e91e80e824d7 [diff] |
[parser] Optimize mayFollowTypeArgs
Doing benchmarks before and after I get the below.
Notice that this is on tokens/ms, i.e. higher is better.
JIT:
pkg/analyzer/lib/src/dart/ast/ast.dart:
```
Difference at 95.0% confidence
1.27922 +/- 0.393002
6.47159% +/- 1.9882%
(Student's t, pooled s = 0.418268)
```
pkg/front_end/lib/src/type_inference/inference_visitor.dart:
```
Difference at 95.0% confidence
0.968609 +/- 0.287367
6.8824% +/- 2.04187%
(Student's t, pooled s = 0.305841)
```
In both cases it processes a little over 6% more tokens per ms.
AOT:
pkg/analyzer/lib/src/dart/ast/ast.dart:
```
Difference at 95.0% confidence
2.39988 +/- 0.429312
9.50898% +/- 1.70105%
(Student's t, pooled s = 0.456911)
```
pkg/front_end/lib/src/type_inference/inference_visitor.dart:
```
Difference at 95.0% confidence
2.28604 +/- 0.279366
12.9521% +/- 1.58282%
(Student's t, pooled s = 0.297326)
```
It processes between 9-13% more tokens per ms.
Additionally, for AOT, I ran it through the benchmarker and got this:
pkg/analyzer/lib/src/dart/ast/ast.dart:
```
msec task-clock:u: -8.5488% +/- 2.1840% (-275.52 +/- 70.39) (3222.95 -> 2947.42)
cycles:u: -8.6402% +/- 2.1619% (-1210657004.60 +/- 302921394.06) (14011942063.40 -> 12801285058.80)
instructions:u: -9.0870% +/- 0.0000% (-2746030853.20 +/- 876.33) (30219334757.30 -> 27473303904.10)
branch-misses:u: -13.3846% +/- 10.1850% (-5542357.40 +/- 4217459.09) (41408381.20 -> 35866023.80)
seconds time elapsed: -8.5442% +/- 2.1816% (-0.28 +/- 0.07) (3.22 -> 2.95)
seconds user: -8.5614% +/- 2.2098% (-0.27 +/- 0.07) (3.20 -> 2.93)
```
pkg/front_end/lib/src/type_inference/inference_visitor.dart
```
msec task-clock:u: -11.6033% +/- 0.9079% (-402.51 +/- 31.50) (3468.96 -> 3066.45)
cycles:u: -11.6826% +/- 0.9053% (-1765194611.60 +/- 136793475.00) (15109578869.80 -> 13344384258.20)
instructions:u: -11.4435% +/- 0.0000% (-3905886611.70 +/- 1150.33) (34131775222.10 -> 30225888610.40)
branch-misses:u: -17.5244% +/- 4.6453% (-8196278.70 +/- 2172645.25) (46770630.60 -> 38574351.90)
seconds time elapsed: -11.6004% +/- 0.9056% (-0.40 +/- 0.03) (3.47 -> 3.07)
seconds user: -11.6215% +/- 0.9879% (-0.40 +/- 0.03) (3.45 -> 3.05)
```
I.e. in both cases it's 8-11% less work (instructions, time etc).
Compiling the CFE with the CFE before and after (AOT) I get this change:
```
msec task-clock:u: -0.4356% +/- 0.3110% (-23.07 +/- 16.47) (5295.49 -> 5272.42)
page-faults:u: 0.1135% +/- 0.0534% (123.64 +/- 58.22) (108956.82 -> 109080.46)
cycles:u: -0.5004% +/- 0.3175% (-109702416.52 +/- 69596415.67) (21921571730.18 -> 21811869313.66)
instructions:u: -0.3994% +/- 0.0005% (-104979706.80 +/- 138268.02) (26284569470.80 -> 26179589764.00)
branch-misses:u: -1.6117% +/- 1.4644% (-1285239.90 +/- 1167813.84) (79746730.52 -> 78461490.62)
seconds time elapsed: -0.4291% +/- 0.3090% (-0.02 +/- 0.02) (5.30 -> 5.28)
seconds user: -0.3992% +/- 0.3801% (-0.02 +/- 0.02) (5.04 -> 5.02)
```
So this improvement to the parser reduces the runtime of compiling by ~0.4%.
Change-Id: Ia89d02e8cce2655fb23ffe18ecbab63521ce75e3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/439721
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Dart is:
Approachable: Develop with a strongly typed programming language that is consistent, concise, and offers modern language features like null safety and patterns.
Portable: Compile to ARM, x64, or RISC-V machine code for mobile, desktop, and backend. Compile to JavaScript or WebAssembly for the web.
Productive: Make changes iteratively: use hot reload to see the result instantly in your running app. Diagnose app issues using DevTools.
Dart's flexible compiler technology lets you run Dart code in different ways, depending on your target platform and goals:
Dart Native: For programs targeting devices (mobile, desktop, server, and more), Dart Native includes both a Dart VM with JIT (just-in-time) compilation and an AOT (ahead-of-time) compiler for producing machine code.
Dart Web: For programs targeting the web, Dart Web includes both a development time compiler (dartdevc) and a production time compiler (dart2js).
Dart is free and open source.
See LICENSE and PATENT_GRANT.
Visit dart.dev to learn more about the language, tools, and to find codelabs.
Browse pub.dev for more packages and libraries contributed by the community and the Dart team.
Our API reference documentation is published at api.dart.dev, based on the stable release. (We also publish docs from our beta and dev channels, as well as from the primary development branch).
If you want to build Dart yourself, here is a guide to getting the source, preparing your machine to build the SDK, and building.
There are more documents in our repo at docs.
The easiest way to contribute to Dart is to file issues.
You can also contribute patches, as described in Contributing.
Future plans for Dart are included in the combined Dart and Flutter roadmap on the Flutter wiki.