fix(files): raise resumable upload chunk size to cut GCS round-trips - #31523
fix(files): raise resumable upload chunk size to cut GCS round-trips#31523mubashir1osmani wants to merge 1 commit into
Conversation
Large vertex/GCS batch uploads surface as 499s (client closed connection) on multi-GB inputs. The event-loop offload already landed; the remaining driver is the 8 MiB resumable chunk size, which made a 2 GB upload roughly 256 strictly-sequential PUTs whose combined round-trip time overran client and load-balancer timeouts. Raise it to 32 MiB (still a 256 KiB multiple, required by GCS for non-final chunks) to cut that to about 64 round-trips. Adds a regression guard on the chunk-size floor, plus a mutation-verified test that a blocking chunk generator does not starve a concurrent coroutine (fails on a synchronous pull, passes with the to_thread offload).
Greptile SummaryThis PR updates the Vertex/GCS resumable file upload path. The main changes are:
Confidence Score: 4/5The change is narrowly scoped to the Vertex/GCS resumable upload path and is covered by targeted tests for chunk sizing and async chunk generation behavior. The implementation keeps the GCS alignment requirement intact, bounds memory to one chunk, and adds regression coverage for the main upload behavior being changed. Live provider validation is still pending because the available project cannot complete the streaming path. No files require follow-up beyond optional live Vertex/GCS validation when an enabled billing project is available.
What T-Rex did
Reviews (1): Last reviewed commit: "fix(files): raise resumable upload chunk..." | Re-trigger Greptile |
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
Relevant issues
Large vertex/Gemini batch file uploads through
/v1/filesreturn 499s (client closed connection) on multi-GB inputs.Linear ticket
Pre-Submission checklist
Please complete all items before asking a LiteLLM maintainer to review your PR
@greptileaiand received a Confidence Score of at least 4/5 before requesting a maintainer reviewScreenshots / Proof of Fix
Real-provider proof is pending; the Vertex project available for local verification has billing disabled, so the live
/v1/files-> GCS path returns a 403 before the upload streams. The change is covered by a mutation-verified regression test (a deliberately blocking chunk generator must not starve a concurrent coroutine; it fails on a synchronous pull and passes with the offload) and a guard on the chunk-size floor. Once a Vertex project with active billing is available, the proof is acurlof a multi-GB batch upload against a live proxy showing the request completing well inside the client timeout.Type
🐛 Bug Fix
Changes
The resumable upload to GCS was using an 8 MiB chunk size, so a 2 GB batch input made roughly 256 strictly-sequential PUTs whose combined round-trip time overran client and load-balancer timeouts and surfaced as a 499. This raises the chunk size to 32 MiB (still a 256 KiB multiple, which GCS requires for non-final chunks), cutting that to about 64 round-trips. Peak memory stays bounded at one chunk, and the request stays synchronous so the returned file object is real and
POST /v1/batcheskeeps working immediately.The companion event-loop offload (pulling each chunk via
asyncio.to_threadso the per-chunk transform does not block the worker) already landed separately; this adds a mutation-verified regression test that guards it.