Repository navigation
feat(relay): use 64 KiB buffers for the none cipher - #2198
Open
pylaterreur wants to merge 2 commits into
Open
pylaterreur wants to merge 2 commits into
pylaterreur wants to merge 2 commits into
Conversation
The none cipher does not frame or encrypt anything, so there is no reason to read in 16 KiB chunks. The AEAD 2022 ciphers already use 64 KiB; do the same here, which halves the syscalls per byte on large transfers. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01GwUvhmzgfkiZ6vo4uGyesN
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The TCP relay of sslocal and ssserver reads in chunks of
plain_read_buffer_size(): 16 KiB for thenonemethod, while the AEAD-2022 methods already use 64 KiB (theirMAX_PACKET_SIZE).nonehas no framing that would tie it to 16 KiB, so this PR uses 64 KiB for it too. On bulk transfers that means up to four times fewerread/writecalls per byte.Measured with sslocal (tunnel) → ssserver → target, method
none, 2 GB per transfer, every transfer checked byte for byte, on loopback. The leg between sslocal and ssserver was plain TCP, then MPTCP (--tcp-multipath). Linux 6.17 on a Ryzen 9 5900X (8-vCPU VM), 5 rounds with the builds alternating within each round, medians. The machine was shared with other VMs (1-minute load 1.6 to 7.3, median 2.9), so throughput varies a lot between runs; the CPU per GB is steadier. CPU is the seconds per GB of each process, lower is better.The cost is memory: the two relay buffers of a
noneconnection grow from 2 × 16 KiB to 2 × 64 KiB, as for the 2022 methods. Nothing else changes; the other methods keep their sizes.Context: OpenMPTCProuter offers
nonefor its shadowsocks-rust proxy, and routers without AES instructions are CPU-bound with the other methods. A separate PR adds asplice(2)path on Linux for the same case; the two are independent.Tests on Linux with Rust 1.99.0:
cargo testof the workspace (default features) and ofcrates/shadowsocks(default and no features), and clippy with CI's flags. No new warnings.🤖 Generated with Claude Code
https://claude.ai/code/session_01GwUvhmzgfkiZ6vo4uGyesN