⚡ perf: Stream BigQuery results to Cloud Storage to prevent OOM#259
⚡ perf: Stream BigQuery results to Cloud Storage to prevent OOM#259max-ostapenko wants to merge 1 commit intomainfrom
Conversation
Refactored the BigQuery to Google Cloud Storage export process to use streams instead of loading the entire result set into a massive memory array. This resolves potential Out-Of-Memory (OOM) errors in Cloud Run and significantly improves overall memory efficiency for large exports. - Updated `infra/dataform-service/src/index.js` to utilize `bigquery.queryResultsStream()`. - Refactored `StorageUpload.exportToJson` in `infra/dataform-service/src/storage.js` to accept a stream. - Implemented a custom `Transform` stream to efficiently format object chunks into a proper JSON array structure while buffering in batches of 1000 for high performance. - Removed unused memory-bound `Readable` initialization from `StorageUpload` constructor.
|
👋 Jules, reporting for duty! I'm here to lend a hand with this pull request. When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down. I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job! For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
💡 What: The optimization implemented
infra/dataform-serviceto use streams when transferring query results from BigQuery to Cloud Storage.Transformstream instorage.jsthat converts the BigQuery rows into a properly formatted JSON array string without keeping the full dataset in memory.index.js.🎯 Why: The performance problem it solves
📊 Measured Improvement:
PR created automatically by Jules for task 13119892305295477544 started by @max-ostapenko