]> Cypherpunks repositories - gostls13.git/commitdiff
runtime: parallel run test
authorqiulaidongfeng <2645477756@qq.com>
Sat, 4 May 2024 07:20:48 +0000 (07:20 +0000)
committerGopher Robot <gobot@golang.org>
Mon, 6 May 2024 17:50:18 +0000 (17:50 +0000)
This CL reduces
the go test runtime time from 130s to 59s.

Change-Id: I91babcd15723a2e7bc706e4e9bddaf3ce39d5b2f
GitHub-Last-Rev: 54c3c82269ca468f5d91fec2af13ee37b975495e
GitHub-Pull-Request: golang/go#65765
Cq-Include-Trybots: luci.golang.try:gotip-linux-386-longtest
Reviewed-on: https://go-review.googlesource.com/c/go/+/564995
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Keith Randall <khr@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
src/runtime/chanbarrier_test.go
src/runtime/hash_test.go

index d4795748bf1ffdb696e5a65a518b710dfc482930..a85984d2d78e6a635c6a530724c9a204e6148f2f 100644 (file)
@@ -45,16 +45,17 @@ func doRequest(useSelect bool) (*response, error) {
 }
 
 func TestChanSendSelectBarrier(t *testing.T) {
+       t.Parallel()
        testChanSendBarrier(true)
 }
 
 func TestChanSendBarrier(t *testing.T) {
+       t.Parallel()
        testChanSendBarrier(false)
 }
 
 func testChanSendBarrier(useSelect bool) {
        var wg sync.WaitGroup
-       var globalMu sync.Mutex
        outer := 100
        inner := 100000
        if testing.Short() || runtime.GOARCH == "wasm" {
@@ -72,12 +73,15 @@ func testChanSendBarrier(useSelect bool) {
                                if !ok {
                                        panic(1)
                                }
-                               garbage = make([]byte, 1<<10)
+                               garbage = makeByte()
                        }
-                       globalMu.Lock()
-                       global = garbage
-                       globalMu.Unlock()
+                       _ = garbage
                }()
        }
        wg.Wait()
 }
+
+//go:noinline
+func makeByte() []byte {
+       return make([]byte, 1<<10)
+}
index 36207e7ed06cb3e2932c5d51f117b32852df3bdf..24c04b260e3841fbf192cec410a6b80c4fcc4b22 100644 (file)
@@ -143,6 +143,7 @@ func TestSmhasherSmallKeys(t *testing.T) {
        if race.Enabled {
                t.Skip("Too long for race mode")
        }
+       testenv.ParallelOn64Bit(t)
        h := newHashSet()
        var b [3]byte
        for i := 0; i < 256; i++ {
@@ -164,6 +165,7 @@ func TestSmhasherSmallKeys(t *testing.T) {
 
 // Different length strings of all zeros have distinct hashes.
 func TestSmhasherZeros(t *testing.T) {
+       t.Parallel()
        N := 256 * 1024
        if testing.Short() {
                N = 1024
@@ -187,6 +189,7 @@ func TestSmhasherTwoNonzero(t *testing.T) {
        if race.Enabled {
                t.Skip("Too long for race mode")
        }
+       testenv.ParallelOn64Bit(t)
        h := newHashSet()
        for n := 2; n <= 16; n++ {
                twoNonZero(h, n)
@@ -232,6 +235,7 @@ func TestSmhasherCyclic(t *testing.T) {
        if race.Enabled {
                t.Skip("Too long for race mode")
        }
+       t.Parallel()
        r := rand.New(rand.NewSource(1234))
        const REPEAT = 8
        const N = 1000000
@@ -261,6 +265,7 @@ func TestSmhasherSparse(t *testing.T) {
        if testing.Short() {
                t.Skip("Skipping in short mode")
        }
+       t.Parallel()
        h := newHashSet()
        sparse(t, h, 32, 6)
        sparse(t, h, 40, 6)
@@ -302,6 +307,7 @@ func TestSmhasherPermutation(t *testing.T) {
        if race.Enabled {
                t.Skip("Too long for race mode")
        }
+       testenv.ParallelOn64Bit(t)
        h := newHashSet()
        permutation(t, h, []uint32{0, 1, 2, 3, 4, 5, 6, 7}, 8)
        permutation(t, h, []uint32{0, 1 << 29, 2 << 29, 3 << 29, 4 << 29, 5 << 29, 6 << 29, 7 << 29}, 8)
@@ -475,6 +481,7 @@ func TestSmhasherAvalanche(t *testing.T) {
        if race.Enabled {
                t.Skip("Too long for race mode")
        }
+       t.Parallel()
        avalancheTest1(t, &BytesKey{make([]byte, 2)})
        avalancheTest1(t, &BytesKey{make([]byte, 4)})
        avalancheTest1(t, &BytesKey{make([]byte, 8)})
@@ -545,6 +552,7 @@ func TestSmhasherWindowed(t *testing.T) {
        if race.Enabled {
                t.Skip("Too long for race mode")
        }
+       t.Parallel()
        h := newHashSet()
        t.Logf("32 bit keys")
        windowed(t, h, &Int32Key{})
@@ -588,6 +596,7 @@ func TestSmhasherText(t *testing.T) {
        if testing.Short() {
                t.Skip("Skipping in short mode")
        }
+       t.Parallel()
        h := newHashSet()
        text(t, h, "Foo", "Bar")
        text(t, h, "FooBar", "")
@@ -798,6 +807,7 @@ func TestCollisions(t *testing.T) {
        if testing.Short() {
                t.Skip("Skipping in short mode")
        }
+       t.Parallel()
        for i := 0; i < 16; i++ {
                for j := 0; j < 16; j++ {
                        if j == i {