Improve performance when running a large number of JUnit tests
まだ誰も着手していません。
評価
- 難易度
- 5/5
- 見積もり時間
- 1週間以上
- 初心者へのやさしさ
- 25/100
- issue の種類
- 機能追加
- 明瞭さ
- 説明が足りない
- 活発さ
- 停滞
- 技術スタック
- java
調査の方向性
まず、issue で説明されている java_test エントリポイントと Bazel テストランナーの動作を追跡します。特に、マクロで生成されたターゲット、@Suite による集約、シャーディング、--flaky_test_attempts がどのように連携するかを確認してください。報告された 2 つのテスト実行と、リンクされている proof of concept を比較します。実装では、報告されているパフォーマンスの増加や、失敗後にすべてのテストを再実行することなしに、大規模なテストコレクションに対応する必要があります。
索引モデルが issue の本文から書いたものです。
説明
Title is a bit vague here, apologies for that.
Out-of-the-box, it is only possible to provide a single entry point to java_test, e.g.
java_test(
name = "com.example.MyLovelyUnitTest",
test_class = "com.example.MyLovelyUnitTest",
srcs = [ ... ],
# etc etc
)
If one wishes to make a target from multiple classes, there are currently two well publicised workarounds:
- Use a macro wrapper;
- Use a
@Suiteor similar.
Unfortunately, each of these comes with a negative side effect wrt. performance:
- Using a macro wrapper to turn the glob of source files into distinct
java_testtargets is documented to have a significant performance impact due to having to create and tear-down workers. To give a rough idea of the impact of this, here are some numbers taken from a Bazel project with ~5000 unit tests using a@Suite:
$ bazel clean
$ time bazel test //... --build_tests_only --test_lang_filters=java --test_size_filters=small
...
Executed 498 out of 498 tests: 498 tests pass.
...
bazel test //... --build_tests_only --test_lang_filters=java 2.58s user 1.55s system 0% cpu 16:41.63 total
... vs using a macro wrapper + aggregate test_suite:
$ bazel clean
$ time bazel test //... --build_tests_only --test_lang_filters=java --test_size_filters=small
...
Executed 4691 out of 4691 tests: 4691 tests pass.
...
./bb bazel bz test //... --build_tests_only --test_lang_filters=java 2.72s user 1.69s system 0% cpu 26:47.95 total
Both of these runs were operating over the same set of tests, but using a separate java_test for each individual class causes the build time to increase by ~60%.
- Generating a
@Suite(either at compile time or dynamically via something likeAllTests) clashes with--flaky_test_attemptsas, if any test case fails, the entire suite is detected as having failed and so all tests are run again. This can be somewhat mitigated by sharding but there's a cap of 50 on the number of shards.
Option 1 is "okay" in cases where there are few, long-running tests; option 2 is "okay" for a lot of fast running tests. It would be nice to have a "one-size-fits-all" solution.
There has been an open issue in the main Bazel repository for a few years now that has a bit of overlap, but that one seems a bit more focused around convenience rather than performance. As the Java rules are being broken out, I thought it might make sense to move it over here for an updated discussion.
When I came across the original issue, I did a very quick-and-hacky PoC of how the built-in Bazel test runner could be updated to support multiple classes; however, on revisiting this I'm not sure if that would actually solve the performance problem on its own, as it looks as though the flaky test attempts is handled outside the test runner process, and so I'm guessing this solution would end up just working in the same way as a @Suite.
- 主要言語
- Starlark
- スター
- 103
- フォーク
- 102
- PR マージ指標
- 30日以内にマージされた PR はありません
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
bazelbuild/rules_java のほかの issue
-
P4
難易度 4/5 3〜5日 初心者へのやさしさ 55/100
bazelbuild/rules_java#360 · コメント 4 件 · リアクション 2 件 ·
-
P4
難易度 5/5 1週間以上 初心者へのやさしさ 35/100
bazelbuild/rules_java#354 · コメント 8 件 ·
-
P3 question
難易度 3/5 1〜2日 初心者へのやさしさ 45/100
bazelbuild/rules_java#339 · コメント 1 件 ·
-
P3
難易度 4/5 3〜5日 初心者へのやさしさ 35/100
bazelbuild/rules_java#325 · コメント 8 件 ·
-
P4
難易度 4/5 3〜5日 初心者へのやさしさ 35/100
bazelbuild/rules_java#316 · リアクション 2 件 ·
bazelbuild/rules_java の issue をすべて見る
似ている issue
-
Name consistency オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
eellak/triplestore#65 · コメント 1 件 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
google-ai-edge/LiteRT-LM#3739 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
-
area-Bzlmod team-ExternalDeps type: bug untriaged
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
bazelbuild/bazel#31291 · コメント 2 件 ·
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
bradcypert/plum#53 ·