summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Martí <mvdan@mvdan.cc>2018-08-08 13:53:10 +0100
committerIan Lance Taylor <iant@golang.org>2018-08-08 13:58:37 +0000
commitbc471a52d7f8f05d631cbda9080f7b21df1f79c5 (patch)
treeffde6f4c147a6bdd56b0f63f7bcef67c42632165
parent15c106d99305411b587ec0d9e80c882e538c9d47 (diff)
downloadgo-git-bc471a52d7f8f05d631cbda9080f7b21df1f79c5.tar.gz
net: reduce TestSplice/big's memory usage
The old code used splice on a 2GB []byte when not in short mode, meaning that running 'go test net' when one had 4GB or less free memory would easily result in "out of memory" runtime panics. Instead, use a much smaller size that is still big enough to not fit into a single splice(2) syscall. The new size is just 5MB, so the test uses a fraction of the memory it used to, and there's no longer a need for a different size on short mode. This also speeds up the test, which goes from ~1.23s to ~0.01s on my laptop. Fixes #26867. Change-Id: Iae1daa5c0995b549f41992f44339be32ca1ee5e4 Reviewed-on: https://go-review.googlesource.com/128535 Run-TryBot: Daniel Martí <mvdan@mvdan.cc> Reviewed-by: Andrei Tudor Călin <mail@acln.ro> Reviewed-by: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
-rw-r--r--src/net/splice_test.go8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/net/splice_test.go b/src/net/splice_test.go
index 2f1e69ddb6..44a5c00ba8 100644
--- a/src/net/splice_test.go
+++ b/src/net/splice_test.go
@@ -80,10 +80,10 @@ func testSpliceMultipleWrite(t *testing.T) {
}
func testSpliceBig(t *testing.T) {
- size := 1<<31 - 1
- if testing.Short() {
- size = 1 << 25
- }
+ // The maximum amount of data that internal/poll.Splice will use in a
+ // splice(2) call is 4 << 20. Use a bigger size here so that we test an
+ // amount that doesn't fit in a single call.
+ size := 5 << 20
srv, err := newSpliceTestServer()
if err != nil {
t.Fatal(err)