Repository navigation
Reuse an SFTP channel for small downloads - #10
Conversation
Share one lazily opened download channel across small files, while keeping large downloads on dedicated channels. Retire the shared channel if a cancelled download stalls during close, and cover reuse, cancellation, fallbacks, and the 8 MiB boundary in tests. For 100 files, measured throughput improved from ~4.1–4.3 to ~14–17 files/s; an app-timed download improved from 24.76 s to 9.7 s.
|
AI review | Looks safe to merge Implements per-session SFTP channel reuse for small files to improve bulk download throughput, with proper fallbacks, cancellation handling, and comprehensive tests. One minor stream-state check may need adjustment for production Node streams. No security or rule violations.
Reviewed d4afb96. AI can be wrong, a maintainer still decides. Comment |
Add a regression test that a finished download keeps the shared channel past the 2 s grace timer and that the next download reuses it. Clarify the comments on the no-op release for shared channels and on the readStream.closed check, after triage-bot review.
Readable.closed is a standard Node stream property. It was added in Node 18, and this repo requires Node ≥ 22.12. It is false while the stream is open and becomes true once the close event fires. I confirmed this on Node 24.15: false before close, true at the close event. So after a normal download !readStream.closed is false and the shared channel is not discarded. Reuse works as intended. The discard path only runs if the stream is still open when the 2 s grace timer fires after a cancel, which is the stalled-close case. |
Reuse one per-session SFTP download channel for files under 8 MiB, reducing channel setup overhead for bulk downloads while keeping large files on dedicated channels. On one host, a 100-file download improved from about 4.1–4.3 to 14–17 files/s; a user-timed download in the Termix app improved from 24.76 s to 9.7 s.
Overview
This PR reuses an SFTP channel for small downloads to improve bulk-download throughput.
Changes Made
MaxSessionsservers, browser saving of 100 files, and UI cancellation were not tested. During a 100-concurrent burst, directory listing took up to about 4.8 s (0.7 s at 16 concurrent, 0.25 s at 4); the old listing latency was not measured, so a regression is not established. Capping frontend concurrency (~16) is a possible separate follow-up.Related Issues
Screenshots / Demos
reuse.an.SFTP.channel.for.small.downloads.Demo.mp4
Checklist
CHANGELOG.md(if the repo has one)CONTRIBUTING.md