Skip to content

Balance the cluster test's shards and cut its waits - #8858

Merged
danlapid merged 2 commits into
mainfrom
dlapid/faster-cluster-test
Nov 25, 2026
Merged

danlapid merged 2 commits into
mainfrom
dlapid/faster-cluster-test

Conversation

@danlapid

Copy link
Copy Markdown
Collaborator

cluster-test ran in 5 shards of 33–52 s each and set timeout = "eternal". Its shards were taken round robin, so the slowest one collected several of the tests that wait out a lease or a drain, and every shard idled for about 3 s after its last test.

  • Balanced shards. COSTS gives a rough cost to each test that takes 3 s or more, and each test goes to the shard with the least cost so far, costliest first. cluster-test now runs in 16 shards, and cluster-cron-test, whose two tests take about 7 s each, in 2.
  • No idle time after the tests. The fake S3's server was unref'd, but the keep-alive connections it had accepted were not, and neither were the delays its faults wait out. The fakes now close once the shard's tests are done, and a delay no longer holds the process open.
  • Shorter waits, same checks:
    • The Cache API test checks its 16 keys side by side, since each write waits out the leases on its own key.
    • The long-turn lease test runs under shortLease, so its turn takes 3 s instead of 7.5 s.
    • The stalled lease-write tests stall the write for 1.5 renewal bounds instead of 3 s. They then wait for the fake to release it, plus two renewals, instead of sleeping 4 s.
    • The SIGTERM-while-starting worker spins 3e8 times instead of 8e8, about 2 s.
  • The eternal timeout is gone.

Measured on remote executors with --runs_per_test=5 (80 cluster-test shard runs per build, all passing):

build before: slowest / mean shard after: slowest / mean shard
debug 46.1 s / 41.1 s 18.1 s / 12.4 s
TSan 52.0 s / 46.4 s 20.7 s / 13.2 s
ASan – 14.9 s / 10.5 s
release – 12.7 s / 8.9 s

The "before" figures come from one run of each of the 5 old shards. After the change, cluster-cron-test takes 6–10 s per shard.

🤖 Generated with Claude Code

danlapid and others added 2 commits November 23, 2026 23:57
Each of cluster-test's 5 shards took 33-52 s, the slowest holding
several of the tests that wait out a lease or a drain, so the test
needed the eternal timeout.

* The shards are balanced by cost rather than taken round robin.
  `COSTS` says about how long each test that takes 3 s or more
  takes, and each test, costliest first, goes to the shard with the
  least cost so far. cluster-test runs in 16 shards, and
  cluster-cron-test, whose two tests take 7 s each, in 2.
* A shard's process outlived its last test by seconds: the fake S3's
  server was unref'd, but the keep-alive connections it had accepted
  were not, nor were the delays its faults wait out. The fakes close
  once the shard's tests are done, and a delay does not hold the
  process.
* The Cache API test checks its 16 keys side by side, as each write
  waits out the leases granted on its key.
* The test of a turn of the event loop that outlasts the lease runs
  under `shortLease`, so that the turn takes 3 s rather than 7.5 s.
* The tests of a stalled lease write stall it for 1.5 renewal bounds
  rather than 3 s, then wait for the fake to let it go on and for two
  renewals past it, rather than sleep 4 s. The fake counts the
  requests a fault delayed whose delay has run out.
* The worker that keeps a server starting spins 3e8 times rather than
  8e8, about 2 s.
* The test no longer sets the eternal timeout.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…-test

# Conflicts:
#	src/workerd/server/tests/cluster/BUILD.bazel
@danlapid
danlapid marked this pull request as ready for review November 25, 2026 20:03
@danlapid
danlapid requested review from a team as code owners November 25, 2026 20:03
@danlapid
danlapid merged commit 830f4c7 into main Nov 25, 2026
24 checks passed
@danlapid
danlapid deleted the dlapid/faster-cluster-test branch November 25, 2026 20:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants