From 44e48c7e6cb0aceccae6535b218748d9f312fc89 Mon Sep 17 00:00:00 2001 From: qiulaidongfeng <2645477756@qq.com> Date: Wed, 1 May 2024 13:42:46 +0000 Subject: hash/maphash: parallel run test This is a reapplication of CL 564576. This reduces the go test hash/maphash time by more than half. After investigation it was confirmed that the original CL would cause OOM when 32-bit machine. This CL add testenv.ParallelOn64Bit for tests that can be parallel on 64-bit machines, it is not parallel on 32-bit machines, because CL 564995 require the same API. Change-Id: I1b7feaa07716cb3f55db4671653348fabf2396b0 GitHub-Last-Rev: 28277255587f6a1b92b9bf1848e1f53adaca64dc GitHub-Pull-Request: golang/go#66359 Cq-Include-Trybots: luci.golang.try:gotip-linux-386-longtest Reviewed-on: https://go-review.googlesource.com/c/go/+/572195 Reviewed-by: Keith Randall Auto-Submit: Keith Randall Reviewed-by: Keith Randall Reviewed-by: David Chase LUCI-TryBot-Result: Go LUCI --- src/internal/testenv/testenv.go | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'src/internal/testenv') diff --git a/src/internal/testenv/testenv.go b/src/internal/testenv/testenv.go index 3b9d2fd1e9..9fb92406e8 100644 --- a/src/internal/testenv/testenv.go +++ b/src/internal/testenv/testenv.go @@ -16,6 +16,7 @@ import ( "flag" "fmt" "internal/cfg" + "internal/goarch" "internal/platform" "os" "os/exec" @@ -511,3 +512,13 @@ func WriteImportcfg(t testing.TB, dstPath string, packageFiles map[string]string func SyscallIsNotSupported(err error) bool { return syscallIsNotSupported(err) } + +// ParallelOn64Bit calls t.Parallel() unless there is a case that cannot be parallel. +// This function should be used when it is necessary to avoid t.Parallel on +// 32-bit machines, typically because the test uses lots of memory. +func ParallelOn64Bit(t *testing.T) { + if goarch.PtrSize == 4 { + return + } + t.Parallel() +} -- cgit v1.3