Skip to content

Optimize SFTP writes - #1603

Open
ddpasa wants to merge 2 commits into
zhanghai:masterfrom
ddpasa:master
Open

Optimize SFTP writes#1603
ddpasa wants to merge 2 commits into
zhanghai:masterfrom
ddpasa:master

Conversation

@ddpasa

@ddpasa ddpasa commented Aug 9, 2026

Copy link
Copy Markdown

I noticed that SFTP writes were extremely slow with MaterialFiles, especially over wireguard networks. After some digging, it turned out that they were bottlenecked by syncronous writes capped by RTT latency. This PR allows for pipelined writes, which leads to massively improved performance. Over my cell phone connection, writes went up from around 150-200 KB/s to over 1.5MB/s.

I think they can be optimized further by being smarter, but this alone gives x10 improvement over the current state.

jsvk added a commit to jsvk/MaterialFiles that referenced this pull request Aug 22, 2026
Squash-merge of upstream PR zhanghai#1603.

Replaces synchronous, RTT-bound SFTP writes with pipelined async writes
(up to 8 in-flight requests via a new PipelinedFileOutputStream), giving
a ~10x throughput improvement on high-latency links. Adds
Client.openOutputStream / SftpFileSystemProvider.newOutputStream, exposes
RemoteFile.asyncWrite through RemoteFileAccessor, and reorders the
copy/close/delete-on-failure logic in SftpCopyMove and ForeignCopyMove so
errors surfaced at close still trigger cleanup. The PR's dav4jvm build
tweak was dropped since this fork already uses the com.github.zhanghai
coordinate.

Original work by ddpasa (https://github.com/ddpasa).

Co-authored-by: ddpasa <112642920+ddpasa@users.noreply.github.com>
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