feat: implement AsyncMultiRangeDownloader with multiplexed bidi-gRPC stream support#16528
Open
zhixiangli wants to merge 3 commits intogoogleapis:mainfrom
Open
feat: implement AsyncMultiRangeDownloader with multiplexed bidi-gRPC stream support#16528zhixiangli wants to merge 3 commits intogoogleapis:mainfrom
zhixiangli wants to merge 3 commits intogoogleapis:mainfrom
Conversation
Contributor
There was a problem hiding this comment.
Code Review
This pull request introduces a _StreamMultiplexer to handle concurrent download tasks over a single bidirectional gRPC stream, replacing the previous locking mechanism in AsyncMultiRangeDownloader. The multiplexer routes responses to per-task asyncio queues based on read_id, allowing for better resource utilization. The lock parameter in download_ranges is now deprecated. Feedback focuses on improving the multiplexer's reliability and performance, specifically by using asyncio.gather to prevent head-of-line blocking during response broadcasting, ensuring the background receive loop terminates when no tasks are active, and adding error logging for observability.
packages/google-cloud-storage/google/cloud/storage/asyncio/_stream_multiplexer.py
Outdated
Show resolved
Hide resolved
packages/google-cloud-storage/google/cloud/storage/asyncio/_stream_multiplexer.py
Show resolved
Hide resolved
packages/google-cloud-storage/google/cloud/storage/asyncio/_stream_multiplexer.py
Show resolved
Hide resolved
13d5d08 to
774d691
Compare
acfab40 to
aed8682
Compare
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.
This PR implements
AsyncMultiRangeDownloaderwith a new_StreamMultiplexer, enabling multiple concurrent range downloads to share a single bidirectional gRPC stream.Before vs. After
How it works
The system uses a background
_StreamMultiplexerto manage the shared bidirectional stream:BidiReadObjectRequest) directly to the shared stream.read_idin each response to route data to the correct task-specificasyncio.Queue._StreamErrorand automatically retry using the new stream generation.Key Changes:
_StreamMultiplexer: Background receiver loop for routing responses.AsyncMultiRangeDownloaderIntegration: Full support for concurrentdownload_rangescalls.