Repository navigation
Make the slowest stream, snapshot and bench tests faster - #8863
Conversation
bb84aa9 to
cbb7222
Compare
cbb7222 to
3a8b88a
Compare
There was a problem hiding this comment.
Superseded by the review of
df76d652.
This review, of 9acbaeab
✅ Approved — No problems found in the test, bench and docs changes. The one known caveat, the capnp-cpp sharding dependency, is already stated in the description.
The decision is advisory: this review is a comment and never approves, blocks or requests changes on the pull request.
✅ All checks passed
🔒 Security: ✅ LGTM
No security concerns in these test and bench changes.
📖 AGENTS.md: ✅ LGTM
The src/tests/streams/digest/AGENTS.md update matches the new GC-pressure test layout.
📋 Code Quality: ✅ LGTM
Snapshot-case coverage, the termination-injection split, the bucket-test pattern() rewrite, the bench-json change and the --quick warmup change all check out. The sharded targets need the capnp-cpp update named in the description to get faster.
⚡ Performance: ✅ LGTM
No performance concerns.
📝 Documentation: ✅ LGTM
The docs/benchmarking.md and docs/startup-snapshot.md updates match the new behaviour.
Reviewed commit: 9acbaeab
9acbaea to
df76d65
Compare
There was a problem hiding this comment.
Superseded by the review of
6066ebca.
This review, of df76d652
✅ Approved — No issues found in this pull request's test, bench and docs changes, including the files changed since the last review.
The decision is advisory: this review is a comment and never approves, blocks or requests changes on the pull request.
✅ All checks passed
🔒 Security: ✅ LGTM
These changes do not touch any production-facing security boundary.
📖 AGENTS.md: ✅ LGTM
The src/tests/streams/digest/AGENTS.md update matches the new GC-pressure test layout.
📋 Code Quality: ✅ LGTM
- Quick-mode warmup (
bench-api/lib.rs,bench-core/lib.rs): withQUICK_WARMUP_NS = 0, each case skips warmup and goes straight to calibration, or to sampling when a batch size is set. Calibration still runs each case at least once before sampling.startup-test.rsnow checks against theQUICK_SAMPLESconstant instead of a literal, so it follows the new value. - Termination-injection split: the loop
for (index = group; index < scenarioCount; index += GROUPS)runs every scenario exactly once across the 7 groups. ATIJ_FILTERthat matches a scenario in another group leaves this group with nothing to run, which is fine for a debugging aid.
⚡ Performance: ✅ LGTM
No performance concerns.
📝 Documentation: ✅ LGTM
The docs/benchmarking.md and docs/startup-snapshot.md updates match the new behaviour.
Reviewed commit: df76d652
df76d65 to
6066ebc
Compare
There was a problem hiding this comment.
Superseded by the review of
5765b2d4.
This review, of 6066ebca
✅ Approved — No issues found in the test, bench, build-macro and docs changes, including those made since the last review.
The decision is advisory: this review is a comment and never approves, blocks or requests changes on the pull request.
✅ All checks passed
🔒 Security: ✅ LGTM
The changes do not touch any production-facing security boundary. In build/deps/gen/deps.MODULE.bazel, the capnp-cpp pin updates the sha256, the strip_prefix and the URL together.
📖 AGENTS.md: ✅ LGTM
The src/tests/streams/digest/AGENTS.md update matches the new GC-pressure test layout.
📋 Code Quality: ✅ LGTM
- bench-core / bench-api:
encode_groupnow returnsVec<u8>, and its callers inrunner.rsandlib-test.rsmatch.words_to_bytesis used correctly byserver/bench.rs.- Startup tests compare against
QUICK_SAMPLESrather than a literal.
- termination-injection-test: the stride loop runs every scenario exactly once across the 7 cases, and
shard_count = 7matches. - startup-snapshot configs: the three configs split the 29 cases between them. An unknown
GROUPfails an assertion. The shared services capnp file is listed in each target'sdata. - bucket-test: every slice of the precomputed run stays in bounds. The expected digest comes from
pattern(), so it is deterministic. - digest gc-pressure:
gc-pressure.jsis left out of the suite glob, so it runs only in its dedicated configs with the V8 flag set. - bench-json: each iteration is now a single encode or decode, and decode uses a fresh builder each time.
⚡ Performance: ✅ LGTM
No performance concerns.
📝 Documentation: ✅ LGTM
The docs/benchmarking.md and docs/startup-snapshot.md updates match the new behaviour.
Reviewed commit: 6066ebca
There was a problem hiding this comment.
Superseded by the review of
fdda15c9.
This review, of 5765b2d4
✅ Approved — No issues found. The only change since the last review is an opt-in shard_count argument in build/kj_test.bzl, passed to both test variants, which leaves tests that don't set it as they were.
The decision is advisory: this review is a comment and never approves, blocks or requests changes on the pull request.
✅ All checks passed
🔒 Security: ✅ LGTM
The kj_test change only affects test sharding and does not touch any security boundary.
📖 AGENTS.md: ✅ LGTM
No AGENTS.md issues found.
📋 Code Quality: ✅ LGTM
build/kj_test.bzl now forwards shard_count = None to both _kj_test instances.
_kj_testis a test rule, so Bazel gives it the standardshard_countattribute.- When the argument is
None, the attribute keeps its default, so tests that don't set it are unchanged. test_attrs()does not also returnshard_count, so it is never passed twice.
⚡ Performance: ✅ LGTM
Sharding is opt-in through shard_count, so tests that don't set it run as before.
📝 Documentation: ✅ LGTM
No documentation issues found.
Reviewed commit: 5765b2d4
There was a problem hiding this comment.
Superseded by the review of
ffa9e66f.
This review, of fdda15c9
✅ Approved — No issues found. The new --quick changes in src/bench/streams/** scale the byte and chunk counts consistently, every expected total is computed from the scaled values, and case names stay unique.
The decision is advisory: this review is a comment and never approves, blocks or requests changes on the pull request.
✅ All checks passed
🔒 Security: ✅ LGTM
The changes affect tests, benchmarks and test or build configuration. None of them touches a security boundary that an untrusted Worker or caller can reach.
📖 AGENTS.md: ✅ LGTM
No issues found in the new or updated AGENTS.md files under src/bench/streams/.
📋 Code Quality: ✅ LGTM
No problems in the --quick scaling under src/bench/streams/**:
- Scaled values. Dividing by 16 gives whole numbers everywhere.
scaled()inbody/helpers.jsguards withMath.max(1, ...). - Case names. Case names still differ under
--quick, so none collide. - Totals and URLs. Every expected total in the
expectEqualchecks, and every service-binding URL, is computed from the scaled count or size. - HTML rewriter.
documentOf()builds the scaled document without ever producing an empty one.
⚡ Performance: ✅ LGTM
The bench-api/runner.rs change is a speedup:
- When the case filter selects every case it is now
None, so the byte-by-byte name matching is skipped. - Group encoding builds its bytes directly.
📝 Documentation: ✅ LGTM
No documentation issues found.
Reviewed commit: fdda15c9
Several tests spent most of their time on work that bought no
coverage, and took tens of seconds under TSan or in debug builds.
* digest: gcDuringCloseOfDroppedStream made 30,000 streams and
30 GB of 1 MiB buffers, 99.5% of each digest suite's time, and
still never hit the use-after-free it was written for. It now runs
alone in digest-gc-pressure-{cpp,ts}.wd-test under
--stress-incremental-marking, which keeps marking in progress so
that cppgc's allocation-limit check finishes a GC inside the close
sink. Without the fix that crashes every ASan run and most debug
runs, within about 10,000 streams.
* termination-injection-test: its scenarios are independent, so
they are split between 7 test cases, which Bazel runs in 7 shards.
* js-readable-stream-test runs its cases in 4 shards.
* startup-snapshot-globals-test: the 29 cases run in three configs,
transferable-v8, transferable-runtime and fallback, so that their
Workers start in parallel. Each case still has its own service.
* bucket-test: pattern() computed 57 MiB a byte at a time in
JavaScript. When V8 left that loop unoptimized, a debug run took
45 to 60 seconds and sometimes timed out. Streams are now copied
from one precomputed run, which also makes the parts of a
multipart write differ from each other, so a completion that
reordered them would fail the digest comparison.
* bench --quick (wd_bench @smoke) takes 2 samples instead of 5 and
no warmup: it checks that each case runs, not how fast.
* bench-json timed each iteration's 10,000 or 100,000 inner
repetitions, so a single benchmark iteration took seconds in debug
builds. Each iteration is now one encode or decode.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The @smoke tests run every case under --quick, which only checks that the case runs. Cases that moved 1 MiB bodies or hundreds of chunks a call took 0.3 to 1.4 seconds a call in TSan and debug builds, so a single group took up to 12 seconds and a whole smoke test up to 35, past the 15 second limit of a medium test in a debug build. Under --quick, these cases now move a sixteenth as many bytes or chunks, and their names show the amounts a run used: * transform: throughput * piping: pipeThrough and pipeTo * body: read, pipe, clone, serviceBinding and htmlRewriter * identity: throughput and pipe * readable: from, asyncIteration and tee * strategies: queueAccounting src/bench/streams/AGENTS.md now asks new cases of this kind to do the same. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
fdda15c to
ffa9e66
Compare
There was a problem hiding this comment.
✅ Approved — No issues found. The new --quick settings (no warmup, 2 samples) work with the runner's handling of a zero warmup, and the startup tests now check QUICK_SAMPLES.
The decision is advisory: this review is a comment and never approves, blocks or requests changes on the pull request.
✅ All checks passed
🔒 Security: ✅ LGTM
The changes only lower the --quick limits for benchmarks. They cross no security boundary.
📖 AGENTS.md: ✅ LGTM
No issues found in the AGENTS.md files.
📋 Code Quality: ✅ LGTM
QUICK_WARMUP_NS = 0 works:
- The runner handles a zero warmup by going straight to calibration, or to sampling when a case has a fixed batch.
- The calibration call still runs each case once before it is sampled.
- The overhead cases use the same constant, and a zero warmup works there too.
budget.warmup_ns = 0gives the same result as the oldmin()would with a cap of 0.
QUICK_SAMPLES = 2 is used the same way across the bench runner and startup groups. The startup-test.rs assertions now check against it.
⚡ Performance: ✅ LGTM
Both changes make --quick runs cheaper. They add no cost to any hot path.
📝 Documentation: ✅ LGTM
No documentation issues found.
Reviewed commit: ffa9e66f
Several tests spent most of their time on work that added no coverage. Under TSan, or in debug builds, they took tens of seconds and sometimes timed out. This PR makes them fast without dropping any assertion.
digest-cpp,digest-ts,digest-cpp-pedanticdigest-gc-pressure-{cpp,ts}(new)streams/termination-injection-test@all-autogatesavg 7–9s, max 26–42s on busy executorsjs-readable-stream-test@all-autogatesstartup-snapshot-globals-test@all-autogatesbody-cpp@smoke,body-ts@smokebody-cpp@all-autogates@smoketransform-cpp@smoke(all variants)throughputalone 7spiping-cpp@smokepipeThroughalone 12s@smoketests changed here (36 targets)bucket-testbench-jsonTimings are from remote test executors. "After" ranges cover 5 runs per variant, and 20 runs per variant for the
@smoketests, whose "Before" is one run of each; bucket-test covers 30 runs each of@,@all-compat-flagsand@all-autogates. Every changed target also passed 5 runs under debug and ASan, where the slowest took 13.7s.Changes
gcDuringCloseOfDroppedStreammade 30,000 streams and allocated 30 GB in 1 MiB buffers. That was 99.5% of each digest suite's time, and it never reproduced the use-after-free it was written for: 0 of 50 runs without the fix. The case now runs alone indigest-gc-pressure-{cpp,ts}.wd-testunder--stress-incremental-marking. Keeping marking in progress lets cppgc's allocation-limit check finish a GC inside the close sink, which destroys the stream under it. Without the fix, the new config crashed in every ASan run (30 of 30) and in 19 of 30 debug runs, after about 10,000 streams.kj_test'sshard_count).transferable-v8,transferable-runtimeandfallback. Their Workers, each built from a zygote and then from its snapshot, start in parallel. The case services live instartup-snapshot-globals-services.capnp. The test no longer needssize = "large".pattern()computed 57 MiB one byte at a time in JavaScript. In the slow debug runs every data-generating step got 40–100x slower and stayed slow. That matches V8 leaving the loop unoptimized: about 1.3 µs per byte. Streams are now copied from one precomputed run. As a side benefit, the 8 MiB parts of a multipart write now differ from one another, so a completion that reordered them would fail the digest check; before, parts 1 and 2 were identical. The test no longer needssize = "large".workerd bench --quick(wd_bench@smoke) now takes 2 samples instead of 5 and does no warmup. It checks that each case runs, not how fast it runs.--quick: cases that moved 1 MiB bodies or hundreds of chunks per call took 0.3–1.4s per call in TSan and debug builds. Under--quickthey now move a sixteenth as many bytes or chunks, and their names show the amounts a run used. This coverstransformthroughput;pipingpipeThroughandpipeTo;bodyread,pipe,clone,serviceBindingandhtmlRewriter;identitythroughputandpipe;readablefrom,asyncIterationandtee; andstrategiesqueueAccounting.src/bench/streams/AGENTS.mdasks new cases like these to do the same.🤖 Generated with Claude Code