Skip to content

Conversation

@Rob-Hague
Copy link
Collaborator

@Rob-Hague Rob-Hague commented Jun 1, 2025

The sftp packet stream runs within but independently of the channel data stream, meaning a channel data packet can contain multiple sftp packets, or an sftp packet can be split across multiple channel data packets.

Normally the packets are sized such there is a 1-to-1 relationship for efficiency. When this doesn't happen the library falls back to buffering via a List<byte>, which is not so efficient. This change uses an array-based buffer instead.

In a sample download which hit this fallback I see about a 20% reduction in memory allocated.

The sftp packet stream runs within but independently of the channel data stream,
meaning a channel data packet can contain multiple sftp packets, or an sftp packet
can be split across multiple channel data packets.

Normally the packets are sized such there is a 1-to-1 relationship for efficiency.
When this doesn't happen the library falls back to buffering via a List<byte>,
which is not so efficient. This change uses an array-based buffer instead.

In a sample download which hit this fallback I see about a 20% reduction in memory
allocated.
@Rob-Hague Rob-Hague merged commit 1f1a5fe into sshnet:develop Jun 6, 2025
4 checks passed
@Rob-Hague Rob-Hague deleted the arraysegment0 branch June 6, 2025 05:35
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