mirror of
https://github.com/netbirdio/gvisor.git
synced 2026-05-22 17:12:49 -07:00
tcp_benchmark: prevent "cheating" with splice
tcp_benchmark is trying to measure the performance of using netstack vs Linux networking. However, Go tries (succeeds) to be smart and figures out it can use splice() to copy between sockets, increasing throughput. That, however, just distorts the benchmark: netstack copies those bytes. In regular use this isn't an issue because netstack isn't hooked up to two sockets, it's hooked up to one socket and one userspace process (usually the sentry). PiperOrigin-RevId: 575257650
This commit is contained in:
committed by
gVisor bot
parent
54ef8c70dd
commit
57606c7aa1
@@ -509,9 +509,14 @@ func main() {
|
||||
}
|
||||
log.Printf("incoming connection established.")
|
||||
|
||||
// Copy both ways.
|
||||
go io.Copy(inConn, next)
|
||||
go io.Copy(next, inConn)
|
||||
// Copy both ways. We wrap everything in another
|
||||
// Reader/Writer to prevent optimizations that
|
||||
// otherwise call splice() to move data between
|
||||
// sockets. That penalizes netstack, but isn't relevant
|
||||
// to real use cases where only one end of netstack is
|
||||
// attached to a socket.
|
||||
go io.Copy(io.MultiWriter(inConn), io.MultiReader(next))
|
||||
go io.Copy(io.MultiWriter(next), io.MultiReader(inConn))
|
||||
|
||||
// Print stats every second.
|
||||
go func() {
|
||||
|
||||
Reference in New Issue
Block a user