aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Bergan <tombergan@google.com>2016-06-29 07:45:23 -0700
committerBrad Fitzpatrick <bradfitz@golang.org>2016-06-29 18:34:53 +0000
commitad82f2cf4b7e8e5f5398b5546b7d834432347355 (patch)
tree9e6033dd5de7a832e19db5eb274992a4825e48c0
parentbb337372fb6e171a6e8a7665ce91eda734f8cdd2 (diff)
downloadgo-ad82f2cf4b7e8e5f5398b5546b7d834432347355.tar.gz
go-ad82f2cf4b7e8e5f5398b5546b7d834432347355.zip
crypto/tls: Use the same buffer size in the client and server in the TLS throughput benchmark
I believe it's necessary to use a buffer size smaller than 64KB because (at least some versions of) Window using a TCP receive window less than 64KB. Currently the client and server use buffer sizes of 16KB and 32KB, respectively (the server uses io.Copy, which defaults to 32KB internally). Since the server has been using 32KB, it should be safe for the client to do so as well. Fixes #15899 Change-Id: I36d44b29f2a5022c03fc086213d3c1adf153e983 Reviewed-on: https://go-review.googlesource.com/24581 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
-rw-r--r--src/crypto/tls/tls_test.go11
1 files changed, 9 insertions, 2 deletions
diff --git a/src/crypto/tls/tls_test.go b/src/crypto/tls/tls_test.go
index b4b5f4a1c6..48b46a003a 100644
--- a/src/crypto/tls/tls_test.go
+++ b/src/crypto/tls/tls_test.go
@@ -538,7 +538,12 @@ func throughput(b *testing.B, totalBytes int64, dynamicRecordSizingDisabled bool
N := b.N
+ // Less than 64KB because Windows appears to use a TCP rwin < 64KB.
+ // See Issue #15899.
+ const bufsize = 32 << 10
+
go func() {
+ buf := make([]byte, bufsize)
for i := 0; i < N; i++ {
sconn, err := ln.Accept()
if err != nil {
@@ -552,7 +557,9 @@ func throughput(b *testing.B, totalBytes int64, dynamicRecordSizingDisabled bool
if err := srv.Handshake(); err != nil {
panic(fmt.Errorf("handshake: %v", err))
}
- io.Copy(srv, srv)
+ if _, err := io.CopyBuffer(srv, srv, buf); err != nil {
+ panic(fmt.Errorf("copy buffer: %v", err))
+ }
}
}()
@@ -560,7 +567,7 @@ func throughput(b *testing.B, totalBytes int64, dynamicRecordSizingDisabled bool
clientConfig := testConfig.clone()
clientConfig.DynamicRecordSizingDisabled = dynamicRecordSizingDisabled
- buf := make([]byte, 1<<14)
+ buf := make([]byte, bufsize)
chunks := int(math.Ceil(float64(totalBytes) / float64(len(buf))))
for i := 0; i < N; i++ {
conn, err := Dial("tcp", ln.Addr().String(), clientConfig)