s3 improvement#93
Conversation
…h transfers
The S3 layer (thaw_common.cloud) rebuilt a fresh boto3 client on every
download and every upload, and had no API for moving many objects at once.
Building a client is ~3 ms warm / ~hundreds of ms cold (credential chain +
S3 service-model load) and — the part that bites on a real network — starts
with an empty connection pool, so each operation paid a fresh TCP+TLS
handshake instead of reusing a warm keep-alive connection. And per
docs/ARCHITECTURE.md a single S3 key is server-throttled to ~135 MB/s flat
regardless of ranged concurrency; the documented unlock is fanning out
across N keys (N×135 MB/s) — which there was no primitive for.
Changes (all additive; existing public APIs and behavior unchanged):
* Shared, thread-safe, process-cached boto3 client keyed by (pid, pool_size).
- pid key: botocore clients are not fork-safe; vLLM forks/spawns TP
workers, so re-keying on os.getpid() rebuilds transparently per process.
- pool_size key: callers needing a bigger HTTP pool get a distinct client.
- Lazy, double-checked build under a lock (boto3.client() construction is
itself not thread-safe; the instance is). reset_s3_client_cache() hook
for test isolation / operator recovery.
* resolve_snapshots(uris, ...) / upload_snapshots(pairs, ...): bounded
cross-file fan-out (THAW_S3_FILE_CONCURRENCY, default 8) reusing the shared
client. Order-preserving, first-error-surfacing, atomic .part rename per
file preserved. resolve_snapshots de-duplicates identical URIs so two
positions can't race the same cache file's rename.
* Honest docstring: replace the unreceipted ">800 MB/s" claim with the
receipted ~135 MB/s single-key wall + the many-key fan-out lever.
Tests: +20 unit tests (client reuse, fork rebuild, reset, batch ordering,
concurrency, bounds, error propagation, dedup) + 3 moto end-to-end batch
tests. Full non-GPU suite: 273 passed. Benchmark (benchmarks/bench_s3_batch.py,
receipt in site/receipts/): client construction 2.83 ms->0.025 ms per op;
256 objects @ 40 ms -> 31.6x with 32-way file concurrency.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
perf(cloud): cache the boto3 S3 client + add bounded-concurrency batc…
|
@karank2512 is attempting to deploy a commit to the Nils 's projects Team on Vercel. A member of the Team first needs to authorize it. |
|
Caution Review failedAn error occurred during the review process. Please try again later. 📝 WalkthroughWalkthroughThe PR adds batch snapshot resolution and upload helpers in ChangesS3 snapshot batching and client reuse
Sequence Diagram(s)Resolve batch flow: sequenceDiagram
participant resolve_snapshots
participant _batch_workers
participant resolve_snapshot_path
resolve_snapshots->>_batch_workers: submit distinct remote URIs
_batch_workers->>resolve_snapshot_path: resolve each URI
resolve_snapshot_path-->>_batch_workers: resolved path
_batch_workers-->>resolve_snapshots: ordered results
Upload batch flow: sequenceDiagram
participant upload_snapshots
participant _batch_workers
participant upload_snapshot
upload_snapshots->>_batch_workers: submit local_path and uri pairs
_batch_workers->>upload_snapshot: upload each pair
upload_snapshot-->>_batch_workers: upload complete
_batch_workers-->>upload_snapshots: completion or first failure
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes Poem
🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
|
yo this is sick — the client caching + the URL dedup before fan-out are exactly right, and the two small things before i merge:
one thing for later, not blocking: the shared client pool is 36 connections but the batch can ask for 8×32=256 in flight, so most of the per-file ranged concurrency isn't actually staying warm in the batch path. correctness is fine, it just means the real fan-out win is bounded by the pool size — we can size the pool for file×per-file when we do the shard-at-freeze work. fix those two and let's merge. great start on the cloud path 🙏 |
Summary by CodeRabbit
New Features
Documentation
Bug Fixes