Skip to content

Native russh SFTP backend + single-copy reads + unified child construction - #19

Merged
hoshimura merged 9 commits into
mainfrom
pr2-native-ssh-and-perf
Oct 5, 2026
Merged

hoshimura merged 9 commits into
mainfrom
pr2-native-ssh-and-perf

Conversation

@hoshimura

Copy link
Copy Markdown
Collaborator

Summary

Replaces the asyncssh Python transport with an off-GIL native russh backend and lands the remaining read/listing perf work (these are interleaved through ssh.py/_child, so they ship together):

  • feat(ssh): native russh SFTP backend — read/write/stat/lstat/list/mkdir/rmdir/unlink/rename/setstat (chmod/chown/utime), ssh_config resolution via ssh2-config, keyboard-interactive auth, and connection pooling. asyncssh is dropped from the runtime (now benchmark-only). Includes host-key None-parity fix.
  • perf(native): single-copy read path for cloud + HTTP backends (reqwest Bytes → Python bytes via PyBytesBuf, eliminating one full-payload memcpy; ~18% faster 64 MiB reads).
  • perf(paths): unify iterdir child construction across all backends via CloudPathMixin._child (14.6× faster SSH child build with ssh_config).

Checklist

  • Tests cover the changed behavior.
  • Documentation reflects user-visible changes.
  • No credentials, private endpoints, or confidential data are included.

@hoshimura hoshimura self-assigned this Oct 2, 2026
@hoshimura
hoshimura force-pushed the pr2-native-ssh-and-perf branch from 119bd55 to a17ae02 Compare October 2, 2026 08:01

@hannabjorgvins hannabjorgvins left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good.

hannabjorgvins
hannabjorgvins previously approved these changes Oct 2, 2026

@hannabjorgvins hannabjorgvins left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good.

- rust/src/ssh.rs: russh + russh-sftp + russh::keys SFTP, pooled sessions,
  host-key verification via check_known_hosts (strict by default)
- ops: read/read_range/write/exists/stat/list/mkdir/rmdir/unlink/rename
- flat connection kwargs spread via _native_kwargs (house **kwargs convention)
- opt-in ASANYPATH_SSH_NATIVE=1; asyncssh stays default (ssh_config, walk, lstat)
- stat/list return full attrs (size,mtime,atime,uid,gid,permissions)
asyncssh disables host-key checking for None; mirror it (and SSH_KNOWN_HOSTS=none
-> ()) so the native backend connects to the same hosts as the default transport.
Return reqwest Bytes straight into Python `bytes` via a PyBytesBuf bridge
instead of body.to_vec() + PyO3 Vec<u8>->bytes. Eliminates one full-payload
memcpy per read across S3/GCS/Azure/Artifactory (get + range_get) and HTTP.
Measured 64MiB read: 69.3 -> 57.0 ms (0.97 -> 1.18 GB/s).
Single fast path for every backend: _child(uri, **attrs) spawns from a
canonical URI (no per-child __init__: scheme re-parse, env read, ssh_config
resolution) and attaches listing-known attrs (SSH _cached_attrs, Artifactory
_is_folder, HTTP _trailing_slash). Replaces the parallel per-backend
`type(self)(...)` / `self / name` child builds in S3/GCS/Azure/Artifactory/
HTTP/SSH/FTP iterdir.

SSH child construction with ssh_config alias resolution: 52.3 -> 3.6 us (14.6x).
- native ssh_lstat + ssh_setstat (chmod/chown/utime)
- native ssh_config resolution via ssh2-config (drop asyncssh parser)
- native keyboard-interactive auth + ssh_disconnect_all
…able

The _HAS_ASYNCSSH conditionals made protocols/auth-show SSH assertions and
scp-style alias tests depend on asyncssh being installed, so they failed on a
clean (no-asyncssh) install. SSH is now native, so assert unconditionally.
@hoshimura
hoshimura force-pushed the pr2-native-ssh-and-perf branch from 5bcc9ea to 4d375c8 Compare October 2, 2026 11:08
@socket-security

Copy link
Copy Markdown

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Addedcargo/​anyhow@​1.0.1048110093100100
Addedcargo/​russh@​0.63.39110093100100
Addedcargo/​russh-sftp@​3.0.110010093100100
Addedcargo/​ssh2-config@​0.8.110010093100100

View full report

@hoshimura
hoshimura merged commit 5a131a5 into main Oct 5, 2026
8 checks passed
@hoshimura
hoshimura deleted the pr2-native-ssh-and-perf branch October 5, 2026 09:28
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.

2 participants