snowflake/common/turbotunnel
David Fifield 839d221883 Take ownership of buffer in QueuePacketConn QueueIncoming/WriteTo.
This design is easier to misuse, because it allows the caller to modify
the contents of the slice after queueing it, but it avoids an extra
allocation + memmove per incoming packet.

Before:
	$ go test -bench='Benchmark(QueueIncoming|WriteTo)' -benchtime=2s -benchmem
	BenchmarkQueueIncoming-4         7001494               342.4 ns/op          1024 B/op          2 allocs/op
	BenchmarkWriteTo-4               3777459               627 ns/op            1024 B/op          2 allocs/op
After:
	$ go test -bench=BenchmarkWriteTo -benchtime 2s -benchmem
	BenchmarkQueueIncoming-4        13361600               170.1 ns/op           512 B/op          1 allocs/op
	BenchmarkWriteTo-4               6702324               373 ns/op             512 B/op          1 allocs/op

Despite the benchmark results, the change in QueueIncoming turns out not
to have an effect in practice. It appears that the compiler had already
been optimizing out the allocation and copy in QueueIncoming.
https://gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/snowflake/-/issues/40187

The WriteTo change, on the other hand, in practice reduces the frequency
of garbage collection.
https://gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/snowflake/-/issues/40199
2022-12-08 08:03:54 -07:00
..
clientid.go Import Turbo Tunnel support code. 2020-04-23 14:00:03 -06:00
clientmap.go Manually unlock the mutex in ClientMap.SendQueue. 2022-12-08 08:03:54 -07:00
clientmap_test.go Manually unlock the mutex in ClientMap.SendQueue. 2022-12-08 08:03:54 -07:00
consts.go Reduce turbotunnel queueSize from 2048 to 512. 2022-12-08 08:03:54 -07:00
queuepacketconn.go Take ownership of buffer in QueuePacketConn QueueIncoming/WriteTo. 2022-12-08 08:03:54 -07:00
queuepacketconn_test.go Take ownership of buffer in QueuePacketConn QueueIncoming/WriteTo. 2022-12-08 08:03:54 -07:00
redialpacketconn.go Import Turbo Tunnel support code. 2020-04-23 14:00:03 -06:00