]> Cypherpunks repositories - gostls13.git/commitdiff
runtime: fix race builders
authorDmitriy Vyukov <dvyukov@google.com>
Tue, 30 Jul 2013 18:13:51 +0000 (22:13 +0400)
committerDmitriy Vyukov <dvyukov@google.com>
Tue, 30 Jul 2013 18:13:51 +0000 (22:13 +0400)
Do not run Syscall benchmarks under race detector,
they split stack in syscall status.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/12093045

src/pkg/runtime/norace_test.go [new file with mode: 0644]
src/pkg/runtime/proc_test.go

diff --git a/src/pkg/runtime/norace_test.go b/src/pkg/runtime/norace_test.go
new file mode 100644 (file)
index 0000000..a3d5b00
--- /dev/null
@@ -0,0 +1,58 @@
+// Copyright 2013 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// The file contains tests that can not run under race detector for some reason.
+// +build !race
+
+package runtime_test
+
+import (
+       "runtime"
+       "sync/atomic"
+       "testing"
+)
+
+// Syscall tests split stack between Entersyscall and Exitsyscall under race detector.
+func BenchmarkSyscall(b *testing.B) {
+       benchmarkSyscall(b, 0, 1)
+}
+
+func BenchmarkSyscallWork(b *testing.B) {
+       benchmarkSyscall(b, 100, 1)
+}
+
+func BenchmarkSyscallExcess(b *testing.B) {
+       benchmarkSyscall(b, 0, 4)
+}
+
+func BenchmarkSyscallExcessWork(b *testing.B) {
+       benchmarkSyscall(b, 100, 4)
+}
+
+func benchmarkSyscall(b *testing.B, work, excess int) {
+       const CallsPerSched = 1000
+       procs := runtime.GOMAXPROCS(-1) * excess
+       N := int32(b.N / CallsPerSched)
+       c := make(chan bool, procs)
+       for p := 0; p < procs; p++ {
+               go func() {
+                       foo := 42
+                       for atomic.AddInt32(&N, -1) >= 0 {
+                               runtime.Gosched()
+                               for g := 0; g < CallsPerSched; g++ {
+                                       runtime.Entersyscall()
+                                       for i := 0; i < work; i++ {
+                                               foo *= 2
+                                               foo /= 2
+                                       }
+                                       runtime.Exitsyscall()
+                               }
+                       }
+                       c <- foo == 42
+               }()
+       }
+       for p := 0; p < procs; p++ {
+               <-c
+       }
+}
index b509826b86eec6c998cb6be6ad737f7e8bae8451..100deb8f238a9e203dd20fd2812b742c1d0e0cce 100644 (file)
@@ -344,49 +344,6 @@ func BenchmarkStackGrowthDeep(b *testing.B) {
        benchmarkStackGrowth(b, 1024)
 }
 
-func BenchmarkSyscall(b *testing.B) {
-       benchmarkSyscall(b, 0, 1)
-}
-
-func BenchmarkSyscallWork(b *testing.B) {
-       benchmarkSyscall(b, 100, 1)
-}
-
-func BenchmarkSyscallExcess(b *testing.B) {
-       benchmarkSyscall(b, 0, 4)
-}
-
-func BenchmarkSyscallExcessWork(b *testing.B) {
-       benchmarkSyscall(b, 100, 4)
-}
-
-func benchmarkSyscall(b *testing.B, work, excess int) {
-       const CallsPerSched = 1000
-       procs := runtime.GOMAXPROCS(-1) * excess
-       N := int32(b.N / CallsPerSched)
-       c := make(chan bool, procs)
-       for p := 0; p < procs; p++ {
-               go func() {
-                       foo := 42
-                       for atomic.AddInt32(&N, -1) >= 0 {
-                               runtime.Gosched()
-                               for g := 0; g < CallsPerSched; g++ {
-                                       runtime.Entersyscall()
-                                       for i := 0; i < work; i++ {
-                                               foo *= 2
-                                               foo /= 2
-                                       }
-                                       runtime.Exitsyscall()
-                               }
-                       }
-                       c <- foo == 42
-               }()
-       }
-       for p := 0; p < procs; p++ {
-               <-c
-       }
-}
-
 func BenchmarkCreateGoroutines(b *testing.B) {
        benchmarkCreateGoroutines(b, 1)
 }