commit e6715cb4ee3e577c83bb4edc40fcc5018ac70bb7 Author: Cecylia Bocovich <coh...@torproject.org> Date: Wed Jul 14 14:42:17 2021 -0400
Increase smux and QueuePacketConn buffer sizes This should increase the maximum amount of inflight data and hopefully the performance of Snowflake, especially for clients geographically distant from proxies and the server. --- client/lib/snowflake.go | 7 ++++++- common/turbotunnel/consts.go | 2 +- server/lib/snowflake.go | 8 +++++++- 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/client/lib/snowflake.go b/client/lib/snowflake.go index 0fc7671..1987cbc 100644 --- a/client/lib/snowflake.go +++ b/client/lib/snowflake.go @@ -21,6 +21,9 @@ const ( SnowflakeTimeout = 20 * time.Second // How long to wait for the OnOpen callback on a DataChannel. DataChannelTimeout = 10 * time.Second + + WindowSize = 65535 + StreamSize = 1048576 //1MB ) type dummyAddr struct{} @@ -224,7 +227,7 @@ func newSession(snowflakes SnowflakeCollector) (net.PacketConn, *smux.Session, e conn.SetStreamMode(true) // Set the maximum send and receive window sizes to a high number // Removes KCP bottlenecks: https://gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/snowflake/-/issues/40026 - conn.SetWindowSize(65535, 65535) + conn.SetWindowSize(WindowSize, WindowSize) // Disable the dynamic congestion window (limit only by the // maximum of local and remote static windows). conn.SetNoDelay( @@ -237,6 +240,8 @@ func newSession(snowflakes SnowflakeCollector) (net.PacketConn, *smux.Session, e smuxConfig := smux.DefaultConfig() smuxConfig.Version = 2 smuxConfig.KeepAliveTimeout = 10 * time.Minute + smuxConfig.MaxStreamBuffer = StreamSize + sess, err := smux.Client(conn, smuxConfig) if err != nil { conn.Close() diff --git a/common/turbotunnel/consts.go b/common/turbotunnel/consts.go index 80f70af..34c474f 100644 --- a/common/turbotunnel/consts.go +++ b/common/turbotunnel/consts.go @@ -11,7 +11,7 @@ import "errors" var Token = [8]byte{0x12, 0x93, 0x60, 0x5d, 0x27, 0x81, 0x75, 0xf5} // The size of receive and send queues. -const queueSize = 32 +const queueSize = 2048 var errClosedPacketConn = errors.New("operation on closed connection") var errNotImplemented = errors.New("not implemented") diff --git a/server/lib/snowflake.go b/server/lib/snowflake.go index 48c6d9e..aa1872f 100644 --- a/server/lib/snowflake.go +++ b/server/lib/snowflake.go @@ -16,6 +16,11 @@ import ( "golang.org/x/net/http2" ) +const ( + WindowSize = 65535 + StreamSize = 1048576 //1MB +) + // Transport is a structure with methods that conform to the Go PT v2.1 API // https://github.com/Pluggable-Transports/Pluggable-Transports-spec/blob/master/releases/PTSpecV2.1/Pluggable%20Transport%20Specification%20v2.1%20-%20Go%20Transport%20API.pdf type Transport struct { @@ -168,6 +173,7 @@ func (l *SnowflakeListener) acceptStreams(conn *kcp.UDPSession) error { smuxConfig := smux.DefaultConfig() smuxConfig.Version = 2 smuxConfig.KeepAliveTimeout = 10 * time.Minute + smuxConfig.MaxStreamBuffer = StreamSize sess, err := smux.Server(conn, smuxConfig) if err != nil { return err @@ -201,7 +207,7 @@ func (l *SnowflakeListener) acceptSessions(ln *kcp.Listener) error { conn.SetStreamMode(true) // Set the maximum send and receive window sizes to a high number // Removes KCP bottlenecks: https://gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/snowflake/-/issues/40026 - conn.SetWindowSize(65535, 65535) + conn.SetWindowSize(WindowSize, WindowSize) // Disable the dynamic congestion window (limit only by the // maximum of local and remote static windows). conn.SetNoDelay( _______________________________________________ tor-commits mailing list tor-commits@lists.torproject.org https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits