Repository navigation
Balance web_canvaskit_tests and web_skwasm_tests subshards by duration - #196260
Conversation
d91473f to
5dd76b6
Compare
| /// Names of all builders in the `flutter/prod` bucket. | ||
| /// | ||
| /// The local .ci.yaml may not match prod, so ask Buildbucket. | ||
| Future<List<String>> listProdBuilders() async { |
There was a problem hiding this comment.
This was moved from _listProdBuilders and the code is unchanged.
| /// Median seconds per file over the last [builds] successful builds of | ||
| /// [builders]. [keyFor] maps a repo-relative test file to its key, or null to | ||
| /// skip it. | ||
| Future<DurationsByFile> sampleDurations( |
There was a problem hiding this comment.
This was moved. shard became the callback so the web script can use it but the loop is unchanged.
| } | ||
|
|
||
| /// ResultDB invocations of the last [count] successful builds of [builder]. | ||
| Future<List<String>> _recentInvocations(String builder, int count) async { |
| return seconds.map((String file, double s) => MapEntry<String, int>(file, s.round())); | ||
| } | ||
|
|
||
| Future<Object?> _rpc(String service, String method, Map<String, Object?> body) async { |
| } | ||
|
|
||
| /// Whole seconds per file in [invocation], keyed by [keyFor]. | ||
| Future<DurationsByFile> _fileDurations( |
There was a problem hiding this comment.
Moved. The only change is the prefix filter and key substring became the callback
|
|
||
| /// Exactly [localFiles] per group. Unsampled files get 0 if another group | ||
| /// sampled them, else the previous value, else the group's median. | ||
| DurationsByGroup reconcile( |
There was a problem hiding this comment.
Moved, logic unchanged, renames only
| }; | ||
| } | ||
|
|
||
| DurationsByGroup readDurations(File file) { |
There was a problem hiding this comment.
This was _readExisting moved, unchanged.
| } | ||
|
|
||
| /// Writes [durations] to [file], sorted. | ||
| void writeDurations(File file, DurationsByGroup durations) { |
There was a problem hiding this comment.
Moved out of main, unchanged.
| stderr.writeln('Wrote ${file.path} (${sorted.values.first.length} files)'); | ||
| } | ||
|
|
||
| int median(List<int> values) { |
| import 'package:http/http.dart' as http; | ||
|
|
||
| /// Whole seconds per test file. | ||
| typedef DurationsByFile = Map<String, int>; |
There was a problem hiding this comment.
This PR looks large but a lot of it was refactoring and renaming. For example DurationsByFile moved from update_tool_test_durations.dart to reuse it in multiple places. DurationsByHost is now DurationsByGroup since the web file groups by renderer.
There was a problem hiding this comment.
Code Review
This pull request refactors the web unit test runner to distribute tests across subshards based on historical durations loaded from a JSON file, and introduces scripts and utilities to sample and update these durations from ResultDB. Feedback on the changes highlights a potential NullError when parsing the durations JSON, a potential StateError if the sorted durations map is empty, and missing documentation comments on public members readDurations and median.
The web unit test shards split packages/flutter/test by file count after a fixed-seed shuffle, so balance is luck: the last prod run's canvaskit shards took 12.7 to 24.0 minutes of tests. Split by measured duration instead, the way flutter#195628 and flutter#195863 do for the tool shards. Durations live in dev/bots/web_test_durations.json, keyed by renderer and repository-relative file, regenerated by update_web_test_durations.dart from ResultDB. _runFlutterWebTest now reports its results to ResultDB so that data exists; this seed was measured from the reporter output of one run. web_test_durations_test keeps the file in sync with the tree. The flutter_web_plugins and flutter_driver web tests are part of the partition instead of an extra on the last shard, each kept together as one unit so they compile once. Predicted from the seed: eight canvaskit shards of 16.6 minutes each instead of 12.7 to 24.0, and two skwasm shards of 10.2. The Buildbucket and ResultDB code shared with update_tool_test_durations.dart moves to test_durations.dart.
9d2685e to
a668522
Compare
Exactly, it takes the median of the last 3 runs. I don't think it's that big a deal for these numbers to be very accurate, just accurate enough for rough time bucketing. You can also rebase your PR onto this one and update the numbers manually based on a local run to see how much they move. |
|
autosubmit label was removed for flutter/flutter/196260, because - The status or check suite ci.yaml validation has failed. Please fix the issues identified (or deflake) before re-applying this label. |
|
autosubmit label was removed for flutter/flutter/196260, because - The status or check suite Presubmit has failed. Please fix the issues identified (or deflake) before re-applying this label. |
|
reason for revert: |
|
Successfully created revert PR: #196580 |
… duration (flutter#196580) Reverts: [Balance web_canvaskit_tests and web_skwasm_tests subshards by duration](flutter#196260) Initiated by: @gaaclarke Reason for reverting: `Mac_arm64 framework_tests_misc` https://ci.chromium.org/ui/p/flutter/builders/prod/Mac_arm64%20framework_tests_misc/15738/overview Original PR Author: @jmagman Reviewed By: @mdebbar The original PR description is provided below: The web unit test shards split files by count after a fixed-seed shuffle. In the latest prod run the eight canvaskit shards took 12.7 to 24.0 minutes of tests. Split by measured duration instead, like flutter#195628 and flutter#195863 did for the tool shards. Durations are in `web_test_durations.json`, regenerated by `update_web_test_durations` from LUCI ResultDB. `_runFlutterWebTest` now reports to ResultDB so that data will exist in the future. But because it's never been uploaded, the checked-in numbers are measured from the reporter output of one run on my machine, not from what's running in CI (it should be regenerated after a few runs in CI). The `flutter_web_plugins` and `flutter_driver` tests are part of the partition instead of an extra on the last shard. Refactored the shared Buildbucket/ResultDB code to `test_durations.dart`. A test in framework_tests_misc fails when the JSON and the tree disagree (and actually [it did fail](https://logs.chromium.org/logs/flutter/buildbucket/cr-buildbucket/8665486458949311825/+/u/run_test.dart_for_framework_tests_shard_and_subshard_misc/stdout) when I rebased this PR!) ``` 00:00 +0 -1: test/web_test_durations_test.dart: canvaskit lists exactly the web unit test files [E] Not in "canvaskit" of dev/bots/web_test_durations.json: packages/flutter/test/widgets/ime_insets_animation_layout_test.dart Either run: dart dev/bots/update_web_test_durations.dart or edit dev/bots/web_test_durations.json by hand with the test file's wall time in seconds. package:matcher fail test/web_test_durations_test.dart 78:9 main.<fn> ``` 8 canvaskit shards should be a balanced 16.6 minutes each instead of 12.7 to 24.0, two skwasm shards should be balanced to 10.2. Part of flutter#146003 and flutter#174961 ## Pre-launch Checklist - [x] I read the [Contributor Guide] and followed the process outlined there for submitting PRs. - [x] I read the [AI contribution guidelines] and understand my responsibilities, or I am not using AI tools. - [x] I read the [Tree Hygiene] wiki page, which explains my responsibilities. - [x] I read and followed the [Flutter Style Guide], including [Features we expect every widget to implement]. - [x] I signed the [CLA]. - [x] I listed at least one issue that this PR fixes in the description above. - [x] I updated/added relevant in-code documentation (doc comments with `///`). - [x] If this PR introduces a new feature or capability, I created and linked a website documentation issue or PR in [flutter/website] (or verified none is needed). - [x] I added new tests to check the change I am making, or this PR is [test-exempt]. - [x] I followed the [breaking change policy] and added [Data Driven Fixes] where supported. - [x] All existing and new tests are passing. If you need help, consider asking for advice on the #hackers-new channel on [Discord]. If this change needs to override an active code freeze, provide a comment explaining why. The code freeze workflow can be overridden by code reviewers. See pinned issues for any active code freezes with guidance. **Note**: The Flutter team is currently trialing the use of [Gemini Code Assist for GitHub](https://developers.google.com/gemini-code-assist/docs/review-github-code). Comments from the `gemini-code-assist` bot should not be taken as authoritative feedback from the Flutter team. If you find its comments useful you can update your code accordingly, but if you are unsure or disagree with the feedback, please feel free to wait for a Flutter team member's review for guidance on which automated comments should be addressed. <!-- Links --> [Contributor Guide]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#overview [AI contribution guidelines]: https://github.com/flutter/flutter/blob/main/CONTRIBUTING.ai.md [Tree Hygiene]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md [test-exempt]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#tests [Flutter Style Guide]: https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md [Features we expect every widget to implement]: https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md#features-we-expect-every-widget-to-implement [CLA]: https://cla.developers.google.com/ [flutter/tests]: https://github.com/flutter/tests [flutter/website]: https://github.com/flutter/website [breaking change policy]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#handling-breaking-changes [Discord]: https://github.com/flutter/flutter/blob/main/docs/contributing/Chat.md [Data Driven Fixes]: https://github.com/flutter/flutter/blob/main/docs/contributing/Data-driven-Fixes.md
flutter/flutter@1b95854...d8bd864 2026-11-16 [email protected] Roll Skia from f2790b0ea630 to 118eaff3deb4 (8 revisions) (flutter/flutter#196661) 2026-11-16 [email protected] [native_assets] Keep a dylib's install name in flutter test when its path does not fit (flutter/flutter#194802) 2026-11-16 [email protected] Reland "[android]: prewarms shaders when the context is created" (flutter/flutter#196579) 2026-11-16 [email protected] [flutter_tools] Bound Browser.close in Chromium.close (flutter/flutter#196211) 2026-11-16 [email protected] Roll Skia from e8ff7a4187ec to f2790b0ea630 (13 revisions) (flutter/flutter#196652) 2026-11-14 [email protected] Revert: Balance web_canvaskit_tests and web_skwasm_tests subshards by duration (flutter/flutter#196580) 2026-11-14 [email protected] Revert: Reland "[android]: prewarms shaders when the context is created" (flutter/flutter#196575) 2026-11-14 [email protected] [flutter_tools] Guard ExtensionManager initialization against concurrent disposal (flutter/flutter#196459) 2026-11-14 [email protected] [ImpellerC] Escape spaces in depfile paths (flutter/flutter#196555) 2026-11-14 [email protected] Reland "[android]: prewarms shaders when the context is created" (flutter/flutter#196549) 2026-11-14 [email protected] Balance web_canvaskit_tests and web_skwasm_tests subshards by duration (flutter/flutter#196260) 2026-11-13 [email protected] Safely return null on malformed stack trace line in StackFrame.fromStackTraceLine (flutter/flutter#194673) 2026-11-13 [email protected] Clarify that super.dispose() must be called synchronously (flutter/flutter#193416) 2026-11-13 [email protected] Consolidate exit-code parameters on runCommand with ExpectedExit (flutter/flutter#196479) 2026-11-13 [email protected] Support multi-view apps in widget test binding (flutter/flutter#194480) 2026-11-13 [email protected] Document using a ListView inside a Column (flutter/flutter#195145) 2026-11-13 [email protected] Add didChangeAlwaysUse24HourFormat to WidgetsBinding and update MediaQuery (flutter/flutter#196117) 2026-11-13 [email protected] Build local engine wasm configs on 32-core Linux bots (flutter/flutter#196284) 2026-11-13 [email protected] [Android] Fix Hybrid Composition resize deadlock (flutter/flutter#196255) 2026-11-13 [email protected] Roll Skia from 11f46cfe8838 to e8ff7a4187ec (9 revisions) (flutter/flutter#196557) 2026-11-13 [email protected] [Impeller] Fix SurfaceContextVK submission tracking and double HostBuffer reset (flutter/flutter#196064) 2026-11-13 [email protected] Manual roll Packages from 14f9933 to 015df97 (5 revisions) (flutter/flutter#196558) 2026-11-13 [email protected] Remove routes_transition_test from widgets (flutter/flutter#186620) 2026-11-13 [email protected] [flutter_tools] Replace TargetPlatform.simpleName with cpuArch (flutter/flutter#196264) 2026-11-13 [email protected] Add a deferred platform-view-created path to the shell and use it on Android (flutter/flutter#196342) 2026-11-13 [email protected] Optimize RenderSliverVariedExtentList and introduce protected itemExtentOf API in RenderSliverFixedExtentBoxAdaptor (flutter/flutter#192384) 2026-11-13 [email protected] Revert: [android]: prewarms shaders when the context is created (flutter/flutter#196468) If this roll has caused a breakage, revert this CL and set the roller to dry run mode using the controls here: https://autoroll.skia.org/r/flutter-packages Please CC [email protected],[email protected] on the revert to ensure that a human is aware of the problem. To file a bug in Packages: https://github.com/flutter/flutter/issues/new/choose To report a problem with the AutoRoller itself, please file a bug: https://issues.skia.org/issues/new?component=1389291&template=1850622 Documentation for the AutoRoller is here: https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
The web unit test shards split files by count after a fixed-seed shuffle. In the latest prod run the eight canvaskit shards took 12.7 to 24.0 minutes of tests. Split by measured duration instead, like #195628 and #195863 did for the tool shards.
Durations are in
web_test_durations.json, regenerated byupdate_web_test_durationsfrom LUCI ResultDB._runFlutterWebTestnow reports to ResultDB so that data will exist in the future. But because it's never been uploaded, the checked-in numbers are measured from the reporter output of one run on my machine, not from what's running in CI (it should be regenerated after a few runs in CI).The
flutter_web_pluginsandflutter_drivertests are part of the partition instead of an extra on the last shard. Refactored the shared Buildbucket/ResultDB code totest_durations.dart.A test in framework_tests_misc fails when the JSON and the tree disagree (and actually it did fail when I rebased this PR!)
8 canvaskit shards should be a balanced 16.6 minutes each instead of 12.7 to 24.0, two skwasm shards should be balanced to 10.2.
Part of #146003 and #174961
Pre-launch Checklist
///).If you need help, consider asking for advice on the #hackers-new channel on Discord.
If this change needs to override an active code freeze, provide a comment explaining why. The code freeze workflow can be overridden by code reviewers. See pinned issues for any active code freezes with guidance.
Note: The Flutter team is currently trialing the use of Gemini Code Assist for GitHub. Comments from the
gemini-code-assistbot should not be taken as authoritative feedback from the Flutter team. If you find its comments useful you can update your code accordingly, but if you are unsure or disagree with the feedback, please feel free to wait for a Flutter team member's review for guidance on which automated comments should be addressed.