⚡ [performance] optimize GCS file metadata fetching#102
⚡ [performance] optimize GCS file metadata fetching#102max-ostapenko wants to merge 1 commit intomainfrom
Conversation
Remove redundant `file.exists()` check and instead rely on catching a 404 error from `file.getMetadata()`. This saves an entire network roundtrip for existing GCS proxy files, halving the network overhead for serving these files. Included a benchmark script to quantify the improvement.
|
👋 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:
Removed the
file.exists()call insrc/controllers/cdnController.jsbefore callingfile.getMetadata(). Wrappedfile.getMetadata()in a try-catch to properly handle 404 errors when a file doesn't exist.🎯 Why:
The previous code made two separate network requests to Google Cloud Storage (one to check existence, another to get the metadata). Since
getMetadata()inherently checks for existence (throwing a 404 if missing), removingexists()reduces network overhead by exactly half for existing files without changing the functionality.📊 Measured Improvement:
Created a mock benchmark (
src/benchmarks/gcs_metadata.benchmark.js) simulating a 50ms GCS network delay.PR created automatically by Jules for task 18322883415643102784 started by @max-ostapenko