perf(cloud): shrink fal cold start by ~20s#1024
Open
emranemran wants to merge 3 commits intomainfrom
Open
Conversation
Three changes that target the cold-start path measured in fal.log: - livepeer_fal_app.py: drop `requirements = [...]` so fal isolate stops provisioning a separate venv on top of the image's. The image already has websockets/httpx/aiokafka via the kafka extra below. - Dockerfile.cloud: pre-build the venv with `uv sync --extra livepeer --extra kafka --no-dev` so the runtime `uv run --extra livepeer --extra kafka livepeer-runner` is a no-op instead of fetching + installing aiokafka, uvloop, and re-resolving ~50 packages. - livepeer_fal_app.py dockerfile_str: re-sync after `COPY src/` so the daydream-scope editable install is refreshed at image build time, eliminating the "Built daydream-scope @ file:///app" rebuild on every cold start. - livepeer_app.py lifespan: pre-warm the pipeline registry so the torch/diffusers/transformers/torchao import cascade runs at runner startup instead of on the first cloud-proxy call (~8s shifted off the user-perceived connect path). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> Signed-off-by: emranemran <emran.mah@gmail.com>
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Contributor
🚀 fal.ai Preview Deployment
Testing on Cloud |
Empty `requirements` broke the wrapper at first websocket — fal isolate runs the App's setup() / websocket handler in a venv separate from the image's /app/.venv (under /usr/local/lib/python3.12/dist-packages), where httpx wasn't available, so check_runner_readiness raised ModuleNotFoundError on every connect. The ~10s cold-start tax that motivated emptying requirements was actually `uv run --extra livepeer --extra kafka` resyncing the image venv, not isolate. The Dockerfile.cloud `uv sync --extra livepeer --extra kafka --no-dev` and the fal-side dockerfile_str re-sync from the previous commit already address that on their own. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> Signed-off-by: emranemran <emran.mah@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Three changes to the fal cold-start path, derived from a real cold-start trace in
fal.log:livepeer_fal_app.py: droprequirements = [...]so fal isolate stops provisioning a separate venv on top of the image's. Combined with the Dockerfile change below, removes the ~10–12sDownloaded transformers / Uninstalled 50 packages / Installed 56 packagesblock visible on every cold start.Dockerfile.cloud: pre-build the venv withuv sync --extra livepeer --extra kafka --no-devso the runtimeuv run --extra livepeer --extra kafka livepeer-runneris a no-op.livepeer_fal_app.pydockerfile_str: re-sync afterCOPY src/so thedaydream-scopeeditable install is refreshed at image build time (kills theBuilt daydream-scope @ file:///apprebuild on every cold start).livepeer_app.pylifespan: pre-warm the pipeline registry so the torch/diffusers/transformers/torchao import cascade runs at runner startup instead of on the first cloud-proxy call (~8s shifted off the user-perceived connect path).Combined expected savings: ~20s of user-visible cold start.
Test plan
uv run ruff check src/scope/cloud/livepeer_app.py src/scope/cloud/livepeer_fal_app.py— cleanuv run ruff format --check— already formattedpy_compile)falSDK loadslivepeer_fal_app.pyand reportsrequirements = []scope-livepeer-emran, force a cold start, capture runner logs, compare phase deltas vs the baselinefal.log. The "Downloaded / Uninstalled / Installed" block should be gone, andRegistry initializedshould fire before the first WS handshake.🤖 Generated with Claude Code