Repository navigation
Shard jsg-test's Rust tests between Bazel test shards - #8856
Conversation
3974be0 to
5d826e3
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #8856 +/- ##
=======================================
Coverage 67.54% 67.54%
=======================================
Files 871 871
Lines 220219 220219
Branches 32916 32916
=======================================
+ Hits 148739 148740 +1
Misses 52041 52041
+ Partials 19439 19438 -1 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
jsg-test has more than a thousand tests. Each creates a V8 isolate, and like every Rust test here they run serially (RUST_TEST_THREADS=1), so the crate's test took about a minute in a debug build and longer under TSan, with no single slow case: about 26 ms per case, nearly all of it isolate setup. It was declared `enormous` to fit. libtest has no sharding of its own and rules_rust's rust_test does not shard either, so wd_rust_test gets a shard_count, which wd_rust_crate passes on as test_shard_count. The rust_test then becomes the manual target <name>@unsharded, and <name> is a test that runs it through //build/rust/test_sharder. That Rust binary lists the libtest tests, keeps every TEST_TOTAL_SHARDS-th one from TEST_SHARD_INDEX, and runs those by exact name, in batches that fit a Windows command line. Each shard is a process of its own and still runs its tests serially, so tests that share process-wide state (static drop counters, autogates) keep working. The sharded test forwards the inner test's clippy and rustfmt checks, which the lint aspects would otherwise never reach on a manual target. jsg-test uses 8 shards and is now `large`. On remote execution, over 40 shard runs each, shards take 10 s on average and at most 19 s in a debug build (the unsharded test took 60 s), and 13 s on average and at most 18 s under TSan (69 s). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
5d826e3 to
ab98e49
Compare
There was a problem hiding this comment.
💬 Approved with comments — The sharding is correct for jsg-test. The two notes are latent edge cases: env values are not location-expanded on the sharded wrapper, and a positional --test_arg filter turns into an exact match once the sharder adds --exact.
Findings: 2 info (2 are inline comments on the diff)
The decision is advisory: this review is a comment and never approves, blocks or requests changes on the pull request.
📋 Code Quality: 💬 2 info
The sharder and macro look correct. Two low-impact edge cases.
Recommendation: 💬 Optional Nits
- [INFO] The sharded test's
envis passed as given, without the location expansion thatrust_testapplies to itsenv. (build/wd_rust_test.bzl:43) - [INFO] A positional
--test_argfilter becomes an exact-name filter in the shard run because--exactis appended. (build/rust/test_sharder/sharder.rs:130)
View full review
- The sharded wrapper sets
envas given, with no$(location ...)/$(rootpath ...)expansion. The innerrust_testdoes get expanded values, but it inherits the wrapper's environment when the sharder starts it. - A positional filter passed with
--test_argmatches by substring when the sharder lists the tests. In the actual run it becomes an exact-name filter, because--exactis added.
✅ All other checks passed
🔒 Security: ✅ LGTM
No security concerns in the sharder or the Bazel rule changes.
📖 AGENTS.md: ✅ LGTM
No issues found.
⚡ Performance: ✅ LGTM
No performance concerns.
📝 Documentation: ✅ LGTM
The shard_count docstring and the checklist addition describe the behaviour accurately.
Reviewed commit: ab98e497
jsg-test has more than a thousand tests. Each one creates a V8 isolate, and like every Rust test here they run serially (
RUST_TEST_THREADS=1). No single case is slow: each takes about 26 ms, nearly all of it isolate setup. Together they took about a minute in a debug build and longer under TSan, so the target was declaredenormous.libtest can't shard and neither can rules_rust's
rust_test, so this adds sharding to the macros:wd_rust_testtakes ashard_count, whichwd_rust_cratepasses on astest_shard_count. Therust_testbecomes the manual target<name>@unsharded, and<name>is a test that runs it through//build/rust/test_sharder.TEST_TOTAL_SHARDS-th one starting atTEST_SHARD_INDEX, and runs those by exact name. The names are passed in batches that fit a Windows command line. Its arguments are passed on to the test binary, so--test_argfilters still narrow the list.clippy_checksandrustfmt_checksoutput groups. Without that, the lint aspects would never reach the manual inner target.jsg-test now uses 8 shards and is
large. Timings on remote execution, over 40 shard runs (5 runs of 8 shards):The 8 shards together run all 1156 tests, each exactly once.
Not tested on Windows or macOS. CI here covers both.
🤖 Generated with Claude Code