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

Abierto
#323 0 comentarios 0 reacciones 1 asignado Ver en GitHub

Los mantenedores suelen responder en 1 día

@inureyes ya está trabajando en esto.

Desde el 5/11/2026.

Evaluación

Dificultad
4/5
Tiempo estimado
3-5 días
Aptitud para principiantes
45/100
Tipo de issue
Nueva funcionalidad
Claridad
Bien especificado
Estado de actividad
Activo
Stack tecnológico
rust
Área
cli, performance

Línea de trabajo

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.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

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.
Lenguaje dominante
Rust
Estrellas
71
Forks
7
Merge medio
4 h 51 min
PR fusionados (30 d)
14

Preparar el entorno

Este proyecto no incluye contenedor de desarrollo, Dockerfile ni guía de contribución, así que la configuración corre por tu cuenta: empieza por su README y consulta nuestra guía para la primera contribución para los pasos generales.

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de lablup/bssh

Todos los issues de lablup/bssh

Issues similares

Más issues de Rust

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.