perf(sftp): adopt the russh-sftp borrowed write API in upload dispatch

Aberta
#323 0 comentários 0 reações 1 responsável Ver no GitHub

Mantenedores costumam responder em até 1 dia

@inureyes já está trabalhando nisso.

Desde 5/11/2026.

Avaliação

Dificuldade
4/5
Tempo estimado
3-5 dias
Facilidade para iniciantes
45/100
Tipo de issue
Funcionalidade
Clareza
Claramente especificada
Status de atividade
Ativa
Stack de tecnologia
rust
Domínio
cli, performance

Direção de pesquisa

Start with src/ssh/tokio_client/sftp_client.rs and read write_all_pipelined, then check whether a russh-sftp release exposes write_nowait_from_slice and Request; the issue says not to start before that release is available. Adapt the upload reader and bounded acknowledgement window while preserving #321's throttling, and run the existing upload tests. Done means file and stdin uploads work and the #322 benchmark reaches within about 5% of upstream io::copy_buf throughput.

Escrita pelo modelo de indexação a partir do texto da issue.

Descrição

priority:medium status:backlog type:performance

Problem / Background

Issue #322 profiled the SFTP upload pipeline against upstream russh-sftp's own copy path (local sftp-server, RTT 0). bssh's SftpClient::upload_from reaches 78-85% of upstream throughput, and roughly 10% of the gap comes from a double copy per chunk: write_all_pipelined (src/ssh/tokio_client/sftp_client.rs) reads into a freshly allocated owned Vec, then the write call serializes that buffer a second time into the outgoing frame.

The fix needs a borrowed, non-awaiting write API that russh-sftp currently keeps private (RawSftpSession::write_nowait_from_slice and the Request handle are pub(crate)). Upstream PR AspectUnk/russh-sftp#105 ("feat(client): expose the borrowed, non-awaiting write") makes both public and re-exports Request from russh_sftp::client. This issue is blocked on that PR being merged and released; as of 2026-10-20 its workflow runs were still awaiting maintainer approval, so expect the wait to take a while. Do not start before a russh-sftp release containing it is available.

Proposed Solution

  • Bump the russh-sftp dependency to a release containing AspectUnk/russh-sftp#105.
  • Rework write_all_pipelined to take an AsyncBufRead reader, dispatch each fill_buf slice with write_nowait_from_slice (no per-chunk Vec allocation, one copy per chunk), and keep a bounded window (VecDeque) of the returned Request handles, awaiting the oldest ack when the window fills so the backpressure behavior added in #321 is preserved.
  • Adapt non-buffered sources (tokio's File does not implement AsyncBufRead) so file and stdin uploads keep working, for example with a BufReader wrapper.
  • Out of scope: the residual multi-threaded scheduling margin measured in #322 (worker handoff cost). This issue only targets the double-copy gap.

Acceptance Criteria

  • The upload path dispatches directly from the reader's borrowed buffer: no per-chunk owned allocation, one copy per chunk.
  • The russh-sftp dependency is updated to a release that publicly exposes write_nowait_from_slice and Request.
  • The in-flight window stays bounded with oldest-first ack collection, and #321's throttle behavior is preserved.
  • File and stdin uploads still work (AsyncBufRead adaptation for non-buffered readers), and existing upload tests pass.
  • The #322 benchmark scenario (local sftp-server, RTT 0, single-threaded runtime) shows the double-copy gap recovered: throughput within about 5% of the upstream io::copy_buf path.
Linguagem predominante
Rust
Estrelas
71
Forks
7
Merge médio
4h 51min
PRs com merge (30d)
14

Preparar o ambiente

Este projeto não oferece contêiner de desenvolvimento, Dockerfile nem guia de contribuição, então a configuração fica por sua conta: comece pelo README e veja nosso guia da primeira contribuição para os passos gerais.

Primeiros passos

  1. Leia a issue inteira e depois o guia de contribuição do projeto.
  2. Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
  3. Faça um fork do repositório e trabalhe em uma branch.
  4. Abra um pull request que referencie o número da issue.

Mais de lablup/bssh

Todas as issues de lablup/bssh

Issues semelhantes

Mais issues de Rust

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.