Przeglądaj źródła

Merge pull request #3 from dolonet/fix/benchmark-lint-and-race

Fix CI: benchmark lint exclusions and data race
pull/434/head
dolonet 1 miesiąc temu
rodzic
commit
fd3670ac9f
No account linked to committer's email address
2 zmienionych plików z 14 dodań i 5 usunięć
  1. 9
    0
      .golangci.toml
  2. 5
    5
      benchmarks/doppel_buf_test.go

+ 9
- 0
.golangci.toml Wyświetl plik

@@ -19,3 +19,12 @@ tests = true
19 19
 #     "thelper",
20 20
 #     "varnamelen",
21 21
 # ]
22
+
23
+# Benchmark and tool code: unchecked Close/Write/Fprintf is fine.
24
+[[linters.exclusions.rules]]
25
+path = 'benchmarks/'
26
+linters = ['errcheck', 'ineffassign']
27
+
28
+[[linters.exclusions.rules]]
29
+path = '_bench_test\.go$'
30
+linters = ['errcheck', 'ineffassign']

+ 5
- 5
benchmarks/doppel_buf_test.go Wyświetl plik

@@ -30,8 +30,8 @@ func stackGoroutineRealistic(done <-chan struct{}, wg *sync.WaitGroup, payload [
30 30
 		//   n, _ := c.p.writeStream.Read(buf[tls.SizeHeader : tls.SizeHeader+size])
31 31
 		//   tls.WriteRecordInPlace(c.Conn, buf[:], n)
32 32
 		copy(buf[sizeHeader:], payload)
33
-		sink = buf[sizeHeader]
34 33
 		<-done
34
+		runtime.KeepAlive(&buf)
35 35
 	}()
36 36
 
37 37
 	// goroutine 2: clock tick loop
@@ -66,9 +66,9 @@ func poolGoroutineRealistic(done <-chan struct{}, wg *sync.WaitGroup, payload []
66 66
 		bp := bufPool.Get().(*[]byte)
67 67
 		buf := *bp
68 68
 		copy(buf[sizeHeader:], payload)
69
-		sink = buf[sizeHeader]
70 69
 		defer bufPool.Put(bp)
71 70
 		<-done
71
+		runtime.KeepAlive(&buf)
72 72
 	}()
73 73
 
74 74
 	// goroutine 2: clock tick loop
@@ -123,8 +123,8 @@ func TestDoppelStackGrowthMechanism(t *testing.T) {
123 123
 				defer wg.Done()
124 124
 				var buf [maxRecordSize]byte
125 125
 				buf[0] = 1
126
-				sink = buf[0]
127 126
 				<-done
127
+				runtime.KeepAlive(&buf)
128 128
 			}()
129 129
 		}
130 130
 		time.Sleep(200 * time.Millisecond)
@@ -154,8 +154,8 @@ func TestDoppelStackGrowthMechanism(t *testing.T) {
154 154
 				defer wg.Done()
155 155
 				var buf [maxRecordSize]byte
156 156
 				copy(buf[sizeHeader:], payload)
157
-				sink = buf[sizeHeader]
158 157
 				<-done
158
+				runtime.KeepAlive(&buf)
159 159
 			}()
160 160
 		}
161 161
 		time.Sleep(200 * time.Millisecond)
@@ -186,9 +186,9 @@ func TestDoppelStackGrowthMechanism(t *testing.T) {
186 186
 				bp := bufPool.Get().(*[]byte)
187 187
 				buf := *bp
188 188
 				copy(buf[sizeHeader:], payload)
189
-				sink = buf[sizeHeader]
190 189
 				defer bufPool.Put(bp)
191 190
 				<-done
191
+				runtime.KeepAlive(&buf)
192 192
 			}()
193 193
 		}
194 194
 		time.Sleep(200 * time.Millisecond)

Ładowanie…
Anuluj
Zapisz