Skip to content

Stop running gtest-parallel unittests twice - #196278

Closed
jmagman wants to merge 2 commits into
flutter:masterfrom
jmagman:drop-gtest-parallel-repeat
Closed

jmagman wants to merge 2 commits into
flutter:masterfrom
jmagman:drop-gtest-parallel-repeat

Conversation

@jmagman

@jmagman jmagman commented Nov 10, 2026

Copy link
Copy Markdown
Member

run_cc_tests passes --repeat=2 to gtest-parallel for every unittest binary. That came from flutter-team-archive/engine#12275 (2019), which ran a whole binary twice in one process with --gtest_repeat=2 --gtest_shuffle to catch test flakes from state left by earlier tests. However, gtest-parallel runs each test in its own process, so the repeat now only runs every test twice. But the engine_v2 recipe already retries a failed step to detect flakiness.

Remove --repeat=2. Halves the engine unittest steps on every host.

Builder now after
Mac mac_host_debug_unopt_arm64 37 min ~30
Mac mac_host_debug_arm64_tests 19 ~16
Mac mac_host_release_arm64_tests 19 ~16
Mac mac_host_profile_arm64_tests 17 ~15.5
Windows windows_unopt 20 ~19
Windows windows_host_engine_test 16 ~15
Linux linux_unopt 16.5 ~16

Retries of those steps halve as well.

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-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.

run_cc_tests passes --repeat=2 to gtest-parallel for every unittest
binary. That came from the 2019 --gtest_repeat=2 --gtest_shuffle flags,
which ran a whole binary twice in one process to catch tests that
depend on state left by earlier tests. gtest-parallel runs each test in
its own process, so the repeat now only runs every test twice, and the
recipe already retries a failed test step.

Halves the engine unittest steps on every host; impeller_unittests on
mac_host_debug_unopt_arm64 goes from 13.6 to about 7 minutes.
@jmagman jmagman added the CICD Run CI/CD label Nov 10, 2026
@github-actions github-actions Bot added the engine flutter/engine related. See also e: labels. label Nov 10, 2026
@jmagman jmagman mentioned this pull request Nov 10, 2026
10 of 11 tasks
@jmagman
jmagman marked this pull request as ready for review November 10, 2026 17:53

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request removes the repeat_flags variable and its associated --repeat=2 flag from the C++ unit test configurations in run_tests.py. This change affects several test suites, including ui_unittests, flow_unittests, txt_unittests, and impeller_unittests, which will no longer run with the repeat flag by default. There are no review comments, and I have no feedback to provide.

@jmagman
jmagman requested a review from gaaclarke November 10, 2026 21:16

@gaaclarke gaaclarke left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

However, gtest-parallel runs each test in its own process, so the repeat now only runs every test twice. But the engine_v2 recipe already retries a failed step to detect flakiness.

The reason for the repeat is to try to catch flakes early. After this change we only rerun after a failure, which is not the same thing as proactively trying to catch flakes.

Considering the engineering cost to hunt down and address flakes I think the infra time is time well spent.

@flutter-dashboard

Copy link
Copy Markdown

CI had a failure that stopped further tests from running. We need to investigate to determine the root cause.

SHA at time of execution: c14c906.

Possible causes:

  • Configuration Changes: The .ci.yaml file might have been modified between the creation of this pull request and the start of this test run. This can lead to ci yaml validation errors.
  • Infrastructure Issues: Problems with the CI environment itself (e.g., quota) could have caused the failure.

A blank commit, or merging to head, will be required to resume running CI for this PR.

Error Details:

FormatException: ERROR: Windows tool_integration_tests_1_10 is a new builder added. it needs to be marked bringup: true
If ci.yaml wasn't changed, try `git fetch upstream && git merge upstream/master`









Stack trace:

#0      CiYaml._validate (package:cocoon_service/src/model/ci_yaml/ci_yaml.dart:395:7)
#1      new CiYaml (package:cocoon_service/src/model/ci_yaml/ci_yaml.dart:128:7)
#2      new CiYamlSet (package:cocoon_service/src/model/ci_yaml/ci_yaml.dart:48:23)
#3      CiYamlFetcher._getCiYaml (package:cocoon_service/src/service/scheduler/ci_yaml_fetcher.dart:124:12)
<asynchronous suspension>
#4      Scheduler.getPresubmitTargets (package:cocoon_service/src/service/scheduler.dart:1154:20)
<asynchronous suspension>
#5      Scheduler._getTestsForStage (package:cocoon_service/src/service/scheduler.dart:1486:14)
<asynchronous suspension>
#6      Scheduler._runCiTestingStage (package:cocoon_service/src/service/scheduler.dart:1527:30)
<asynchronous suspension>
#7      Scheduler.proceedToCiTestingStage (package:cocoon_service/src/service/scheduler.dart:1636:7)
<asynchronous suspension>
#8      Scheduler._closeSuccessfulEngineBuildStage (package:cocoon_service/src/service/scheduler.dart:1421:5)
<asynchronous suspension>
#9      Scheduler.processBuildCompleted (package:cocoon_service/src/service/scheduler.dart:1362:11)
<asynchronous suspension>
#10     PresubmitSubscription._processBuild (package:cocoon_service/src/request_handlers/presubmit_subscription.dart:228:7)
<asynchronous suspension>
#11     PresubmitSubscription.post (package:cocoon_service/src/request_handlers/presubmit_subscription.dart:119:5)
<asynchronous suspension>
#12     RequestHandler.service (package:cocoon_service/src/request_handling/request_handler.dart:42:20)
<asynchronous suspension>
#13     SubscriptionHandler.service (package:cocoon_service/src/request_handling/subscription_handler.dart:134:5)
<asynchronous suspension>
#14     createServer.<anonymous closure> (package:cocoon_service/server.dart:462:7)
<asynchronous suspension>
#15     main.<anonymous closure>.<anonymous closure> (file:///app/app_dart/bin/gae_server.dart:192:9)
<asynchronous suspension>

@jmagman

jmagman commented Nov 10, 2026 •

Copy link
Copy Markdown
Member Author

The reason for the repeat is to try to catch flakes early. After this change we only rerun after a failure, which is not the same thing as proactively trying to catch flakes.

If the test never fails (and therefore never re-runs) it's not flaky, right?

Considering the engineering cost to hunt down and address flakes I think the infra time is time well spent.

I'm saying I don't think the original premise as this helping to track down flakes is correct. Chinmay wrote:

That is, they must not rely on global state set by other tests that have already run in the process. Also, these tests must themselves be repeatable. That is, they must correctly clean up after themselves and be able to run successfully again in the same process.

However, gtest-parallel doesn't run them the same process for a --repeat

The script works by listing the tests of each binary, and then executing them on workers in separate processes.

https://github.com/google/gtest-parallel#gtest-parallel

When this was done in 2019 it was a good idea to re-run the tests to find flakes. However, since that PR, the engine_v2 recipe already handles re-running tests when they fail, reports flakes to the backend, files issues, etc. Running --repeat 2 underneath that mechanism may actually undermine the superior flake detection that the recipe already does.

@gaaclarke

Copy link
Copy Markdown
Member

@jmagman I think there is some confusion about what the --repeat=2 does. It means "run each test twice, if any one of them fails, the whole run is considered a failure". It doesn't mean "run each test, if it fails, run it again, and the whole run is considered a success if at least one of each of them passes."

The first thing helps use identify flakes early, the second thing is what is provided by engine_v2. They are kind of at odds with with each other. It's been a while since I dusted off my Bayesian probability but the current setup will catch more flakes than just running the tests once. A quick query to gemini says the current setup has a 56% chance of identifying a test that is 50% flakey. Whereas the proposed change has a 25% chance.

Details

query:

I have 2 setups, what is the probability of running into the event in these 2 scenarios where the event is 50% likely:

  1. The scenario is executed twice, if either of them happen, then are run twice again. If on the second time the event happened, that is a positive outcome.
  2. The scenario is executed once, if it happens, it is executed again. If the second time the event happens, that is a positive outcome.

The thing chinmay is talking about is just how gtest_parallel works in general with spawning subprocesses to execute tests.

@jmagman

jmagman commented Nov 11, 2026

Copy link
Copy Markdown
Member Author

"run each test, if it fails, run it again, and the whole run is considered a success if at least one of each of them passes."

I wouldn't call the engine_v2 reruns as "successes", it registers the flakes and files the GitHub issues with all the flake information like flake rate and runs where it's flaking so they can be investigated, which is actually actionable for flake investigation. However I don't care that deeply about this one. File it away in the noggin if this becomes a long-pole for engine presubmits.

Thanks for looking into it!

@jmagman jmagman closed this Nov 11, 2026
LongCatIsLooong pushed a commit to LongCatIsLooong/flutter that referenced this pull request Nov 16, 2026
Skip the Vulkan `impeller_unittests` on macOS. Vulkan there is
SwiftShader with validation, the same configuration `Linux linux_unopt`
has run for every Vulkan test since flutter-team-archive/engine#50558. Metal is the
macOS-only coverage and still runs.
Example Linux run:
https://logs.chromium.org/logs/flutter/buildbucket/cr-buildbucket/8665483521497042033/+/u/test:_Host_Tests_for_host_debug_unopt_impeller_tests__2_/stdout

Linux only ran `impeller_unittests` in the debug unopt build, so to keep
optimized Vulkan coverage, `ci/host_profile_test` and
`ci/host_release_test` now run them too.


Vulkan is ~76 of the ~108 CPU-min in this step, so `impeller_unittests`
drops from ~13.6 min to ~4 min on each Mac host builder:
| Builder | Before | After |
|---|---|---|
| Mac mac_host_debug_unopt_arm64 | 37 min | ~28 min |
| Mac mac_host_debug_tests / release_tests | 19 min | ~15.5 min |
| Mac mac_host_profile_tests | 17 min | ~15 min |

With flutter#196278 as well, `impeller_unittests` on
`mac_host_debug_unopt_arm64` goes from 13.6 to about 2 minutes.


## 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].
- [ ] 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CICD Run CI/CD engine flutter/engine related. See also e: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants