Skip to content

Optimize SFTP download performance with background prefetching and range parallelism - #36

Merged
VulcanoSoftware merged 2 commits into
mainfrom
sftp-download-speed-optimization-10218746665379169542
Sep 2, 2026
Merged

Optimize SFTP download performance with background prefetching and range parallelism#36
VulcanoSoftware merged 2 commits into
mainfrom
sftp-download-speed-optimization-10218746665379169542

Conversation

@VulcanoSoftware

Copy link
Copy Markdown
Owner

This change significantly improves SFTP download speeds:

  1. Implemented asynchronous background prefetching in DCFSSFTPBufferedFile via a background worker pushing stream chunks into a bounded asyncio.Queue. Subsequent SFTP read() calls are served directly from RAM without waiting on sequential network round-trips.
  2. Updated is_big_file threshold to 2MB so standard 8MB Discord parts trigger parallel HTTP Range downloads from Discord CDN.
  3. Increased default download_max_concurrent_parts to 6 for higher part concurrency during multi-part file downloads.
  4. Added new test cases in tests/test_sftp_handler.py and updated config/utility tests.

PR created automatically by Jules for task 10218746665379169542 started by @VulcanoSoftware

… and parallel ranges

- Implement asynchronous background prefetching in `DCFSSFTPBufferedFile` using `asyncio.Queue` so SFTP read loops serve chunks directly from RAM without sequential RTT delays.
- Lower `is_big_file` threshold in `dcfs/utils/others.py` to 2MB to trigger `download_file_parallel` Range requests for standard 8MB Discord file parts.
- Increase default `download_max_concurrent_parts` from 3 to 6 in `dcfs/config.py` and `dcfs/core/client.py`.
- Add unit tests for SFTP prefetching error propagation and lifecycle cleanup.

Co-authored-by: VulcanoSoftware <113239901+VulcanoSoftware@users.noreply.github.com>
@google-labs-jules

Copy link
Copy Markdown
Contributor

👋 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 @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

… and parallel ranges

- Implement asynchronous background prefetching in `DCFSSFTPBufferedFile` using `asyncio.Queue` so SFTP read loops serve chunks directly from RAM without sequential RTT delays.
- Lower `is_big_file` threshold in `dcfs/utils/others.py` to 2MB to trigger `download_file_parallel` Range requests for standard 8MB Discord file parts.
- Increase default `download_max_concurrent_parts` from 3 to 6 in `dcfs/config.py` and `dcfs/core/client.py`.
- Add unit tests for SFTP prefetching error propagation and lifecycle cleanup.

Co-authored-by: VulcanoSoftware <113239901+VulcanoSoftware@users.noreply.github.com>
@VulcanoSoftware
VulcanoSoftware marked this pull request as ready for review September 2, 2026 08:30
@VulcanoSoftware
VulcanoSoftware merged commit e3feed6 into main Sep 2, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant