Optimize SFTP download performance with persistent streaming#33
Optimize SFTP download performance with persistent streaming#33VulcanoSoftware wants to merge 2 commits into
Conversation
Modified `DCFSSFTPBufferedFile` to maintain an active download stream across multiple `read` calls. This eliminates the massive overhead of re-initializing the stream and re-downloading/decrypting the same ciphertext chunks for sequential small reads, which was previously limiting download speeds to ~30 KBps. Changes: - Added `_read_stream`, `_read_iter`, and `_read_pos` to track streaming state. - Implemented offset-based seek detection to reuse the stream or re-initialize if needed. - Added `_read_lock` for task-safety during concurrent reads. - Cached file attributes in `fstat` to reduce redundant metadata lookups. - Ensured proper cleanup of the download stream in `close()` and during seeks. Co-authored-by: VulcanoSoftware <113239901+VulcanoSoftware@users.noreply.github.com>
|
👋 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. |
Mypy complained about `anext` receiving an `Optional[AsyncIterator]`. Added a cast to satisfy the type checker, as the logic ensures the iterator is not None at that point. Co-authored-by: VulcanoSoftware <113239901+VulcanoSoftware@users.noreply.github.com>
Optimized SFTP download speeds by implementing a persistent streaming mechanism in
DCFSSFTPBufferedFile. Previously, every SFTPreadrequest (often 32KB) would open a new download stream from the backend. This was particularly slow with encryption enabled, as each plaintext read required re-downloading and re-decrypting at least one 64KB ciphertext chunk. The new implementation keeps the stream open and reuses it for sequential reads, significantly reducing CDN overhead and CPU usage. It also includes attribute caching forfstatand proper resource management viaaclose().PR created automatically by Jules for task 1456466687842950070 started by @VulcanoSoftware