fix: goroutine stuck on edge case (#1495)

* fix: goroutine stuck on edge case

* refactor: simplify mapreduce implementation
This commit is contained in:
Kevin Wan
2022-01-30 13:09:21 +08:00
committed by GitHub
parent 14a902c1a7
commit 6c2abe7474
3 changed files with 115 additions and 19 deletions

View File

@@ -18,9 +18,9 @@ import (
func FuzzMapReduce(f *testing.F) {
rand.Seed(time.Now().UnixNano())
f.Add(int64(10), runtime.NumCPU())
f.Fuzz(func(t *testing.T, n int64, workers int) {
n = n%5000 + 5000
f.Add(uint(10), uint(runtime.NumCPU()))
f.Fuzz(func(t *testing.T, num uint, workers uint) {
n := int64(num)%5000 + 5000
genPanic := rand.Intn(100) == 0
mapperPanic := rand.Intn(100) == 0
reducerPanic := rand.Intn(100) == 0
@@ -56,7 +56,7 @@ func FuzzMapReduce(f *testing.F) {
idx++
}
writer.Write(total)
}, WithWorkers(workers%50+runtime.NumCPU()))
}, WithWorkers(int(workers)%50+runtime.NumCPU()/2))
}
if genPanic || mapperPanic || reducerPanic {