[analyzer] Avoid allocation on FormalParameterElementImpl.name With https://dart-review.googlesource.com/c/sdk/+/515400 each time FormalParameterElementImpl.name is called (when analyzing the CFE this happens more than 1 million times) we allocate a list, allocate an iterator for the list and loop through it. According to golem the change cost ~214 million instructions and ~59 mb additional allocation. This CL gets rid of the allocation while attempting to keep a "dart vibe" of the code in `FormalParameterElementImpl.name`. Normally a pattern like this would introduce a closure and whatnot, but at least for now the `@pragma("vm:prefer-inline")` works and the whole thing is inlined avoiding allocation. With normal GC: ``` task-clock:u: -3.6066% +/- 1.3083% (-399049693.40 +/- 144751775.28) (11064440065.60 -> 10665390372.20) page-faults:u: -1.8142% +/- 0.2043% (-3511.40 +/- 395.51) (193547.90 -> 190036.50) cycles:u: -3.7105% +/- 1.3264% (-1733146413.80 +/- 619530940.49) (46708752064.20 -> 44975605650.40) instructions:u: -2.3466% +/- 0.0014% (-1325651734.40 +/- 809878.15) (56492424294.70 -> 55166772560.30) branch-misses:u: -7.0551% +/- 2.7318% (-13222134.20 +/- 5119652.45) (187411563.20 -> 174189429.00) seconds time elapsed: -3.6019% +/- 1.3110% (-0.40 +/- 0.15) (11.07 -> 10.67) seconds user: -3.8894% +/- 1.3469% (-0.42 +/- 0.14) (10.74 -> 10.32) maxRssKbytes: 0.2461% +/- 0.0191% (1510.00 +/- 117.45) (613676.40 -> 615186.40) maxRssBytes: 0.2461% +/- 0.0191% (1546240.00 +/- 120267.81) (628404633.60 -> 629950873.60) Comparing GC data: Scavenge( new space) goes from 166 to 164 MarkSweep( promotion) goes from 16 to 15 MarkSweep( old space) goes from 0 to 1 Notice combined GC time goes from 3629 ms to 3455 ms (notice only 1 run each). ``` With GC disabled: ``` task-clock:u: -2.0544% +/- 0.8486% (-353259971.90 +/- 145910425.38) (17194925559.80 -> 16841665587.90) page-faults:u: -1.2594% +/- 0.0284% (-15025.20 +/- 338.76) (1193070.30 -> 1178045.10) cycles:u: -2.2676% +/- 0.9083% (-1500656743.20 +/- 601102816.18) (66177563665.30 -> 64676906922.10) instructions:u: -0.4887% +/- 0.0004% (-191480701.90 +/- 166586.57) (39180445183.20 -> 38988964481.30) seconds time elapsed: -2.0540% +/- 0.8468% (-0.35 +/- 0.15) (17.20 -> 16.85) seconds user: -2.4899% +/- 1.0499% (-0.38 +/- 0.16) (15.43 -> 15.05) maxRssKbytes: -1.2579% +/- 0.0069% (-60240.00 +/- 328.16) (4788987.60 -> 4728747.60) maxRssBytes: -1.2579% +/- 0.0069% (-61685760.00 +/- 336030.87) (4903923302.40 -> 4842237542.40) ``` Change-Id: I2a4daf7238a9b69b4759dff9845606fcd5628fb9 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/516800 Reviewed-by: Johnni Winther <johnniwinther@google.com> Commit-Queue: Jens Johansen <jensj@google.com> https://dart.googlesource.com/sdk/+/9ee7c8c407d4d4178368f5d4b86a25a3fb5c6ac2
Monorepo is:
With depot_tools installed and on your path, create a directory for your monorepo checkout and run these commands to create a gclient solution in that directory:
mkdir monorepo cd monorepo gclient config --unmanaged https://dart.googlesource.com/monorepo gclient sync -D
This gives you a checkout in the monorepo directory that contains:
monorepo/ DEPS - the DEPS used for this gclient checkout commits.json - the pinned commits for Dart, flutter/engine, and flutter/flutter tools/ - scripts used to create monorepo DEPS engine/src/ - the flutter/buildroot repo flutter/ - the flutter/engine repo out/ - the build directory, where Flutter engine builds are created third_party/ - Flutter dependencies checked out by DEPS dart/ - the Dart SDK checkout. third_party - Dart dependencies, also used by Flutter flutter/ - the flutter/flutter repo
Flutter's instructions for building the engine are at Compiling the engine
They can be followed closely, with a few changes:
goma_ctl ensure_start is sufficient.Example build commands that work on linux:
MONOREPO_PATH=$PWD if [[ ! $PATH =~ (^|:)$MONOREPO_PATH/flutter/bin(:|$) ]]; then PATH=$MONOREPO_PATH/flutter/bin:$PATH fi export GOMA_DIR=$(dirname $(command -v gclient))/.cipd_bin goma_ctl ensure_start pushd engine/src flutter/tools/gn --goma --no-prebuilt-dart-sdk --unoptimized --full-dart-sdk autoninja -C out/host_debug_unopt popd
The Flutter commands used to build and run apps will use the locally built Flutter engine and Dart SDK, instead of the one downloaded by the Flutter tool, if the --local-engine option is provided.
For example, to build and run the Flutter spinning square sample on the web platform,
MONOREPO_PATH=$PWD cd flutter/examples/layers flutter --local-engine=host_debug_unopt \ -d chrome run widgets/spinning_square.dart cd $MONOREPO_PATH
To build for desktop, specify the desktop platform device in flutter run as -d macos or -d linux or -d windows. You may also need to run the command
flutter create --platforms=windows,macos,linux
on existing apps, such as sample apps. New apps created with flutter create already include these support files. Details of desktop support are at Desktop Support for Flutter
Tests in the Flutter source tree can be run with the flutter test command, run in the directory of a package containing tests. For example:
MONOREPO_PATH=$PWD cd flutter/packages/flutter flutter test --local-engine=host_debug_unopt cd $MONOREPO_PATH
Please file an issue or email the dart-engprod team with any problems with or questions about using monorepo.
We will update this documentation to address them.
flutter commands may download the engine and Dart SDK files for the configured channel, even though they will be using the local engine and its SDK.gclient sync needs to be run in an administrator session, because some installed dependencies create symlinks.