← Back to Pull requests

Keep r2-test's largeListings within its time limit #8836

Closed
unknown closed this pull request without merging on Nov 23, 2026 23:09 UTC
View on GitHub
unknown unknown commented on Nov 23, 2026 19:13 UTC
Author

This stops //src/workerd/server/tests/r2:r2-test from timing out at
its 15 s limit in CI.

Since R2 buckets landed in #8507 on Nov 19, it timed out in 12 jobs
among failed Tests runs: 5 on test-linux, 4 of them on main; 4 on
Windows; 3 on Linux ASan; plus one on arm64 debug. Every timeout was
inside largeListings.

That case wrote, listed, and deleted two sets of 100 objects with large
metadata. It slowed down far more than the other cases under parallel
load: locally, it took 0.9 s of the test's 1.5 s alone in fastbuild and
4.7-5.8 s of 6.7-7.0 s with 18 tests in parallel. This points at its
many small file operations. A CPU profile showed no hot spot and
nothing quadratic or blocking.

The two commits make these changes:

r2.js: A listing that includes metadata HEADed every object the
store listed, up to 1000, and then kept only the roughly 40 that fit
the 512 KiB reply. It now takes items 16 at a time in the store's
order, HEADs the objects among them at once, and stops at the first
item past the budget.

The reply differs in two cases:

An uncut reply's objects and prefixes are now in the order of
compare, UTF-8 byte order, rather than as the store listed them.
These are the same for the local store and for S3 and GCS, which
list in that order.
The objects of batches past the budget are not HEADed, so a HEAD of
one that would have failed other than with a 404 no longer fails
the listing.

This barely speeds up the test, but avoids hundreds of wasted HEADs
on large real listings.

New tests pin both behaviours. A second r2 Worker in the test runs
the same r2.js over the same bucket through a small probe Worker
that counts HEADs and fails the HEAD of one key past the budget; the
listing must succeed and HEAD fewer objects than it lists.
listingOrder checks that an uncut reply of objects and prefixes
comes back in UTF-8 byte order, with keys whose UTF-16 order differs.

r2-test.js: largeListings now uses one set of 50 objects with
3,600 CJK characters of metadata, each followed by a key under a
1 KB prefix. It lists the set with and without a delimiter. Both
listings still span two pages, and the delimited one has about 5 KB
of budget to spare. The page count checks that the budget counts
bytes, not characters: it would fit in one page if characters were
counted.

The test cannot tell whether the cursor skips a prefix's keys because
the local store already skips a common prefix at or before
start-after. The old test could not tell either.

The test's size and 15 s limit are unchanged.

Results

Local timings (medians, except the parallel row):

| largeListings | Before | After |
| --- | --- | --- |
| Alone, fastbuild | 888 ms | 493 ms |
| 18 runs in parallel | 4.7-5.8 s | 2.1-2.3 s |

Twenty runs each of r2-test@, @all-autogates,
@all-compat-flags, and r2-wrangler-test all passed, 18 at a time.
r2-test averaged 3.5-4.2 s, with a maximum of 4.4 s. Alone, the
whole test takes 1.2 s instead of 1.5 s in fastbuild.
workerd-server_test and the cluster tests, which also list through
r2.js, pass.

Lines changed

| Kind | Added | Removed |
| --- | ---: | ---: |
| Implementation | 30 | 17 |
| Tests | 137 | 45 |

Diff: 409 lines (+306 / -103) across 5 files Reviewer: piscisaureus Review duration: 235m
All Vouch review confidence checks passed
Residual risk 0.18 = Change Risk (0.45) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.45 · 409 lines diff across 5 files
0.45
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
0.17
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
60%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size diff_size
0.360
Shallow Review Depth shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #8836"
general weight: 0.35
Reviewers
Assignees
Unassigned
Labels
risk: low confidence: 60.5% reviewed
Vouch Risk Breakdown
AI-powered review risk analysis
Change Risk
Change Risk · Model 1 (XGBoost)
Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
Score: 44.9% (MEDIUM) · Higher = larger blast radius
44.9%
Review Confidence
Review Confidence · Models 2 & 3
Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
Score: 60.5% · Lower = rushed or shallow review
60.5%
Residual Risk
Residual Risk · Core Equation
Residual = Change × (1 − Confidence)
Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
Score: 17.7% · Safe to merge
17.7%