-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathworkpool_test.go
668 lines (623 loc) · 18.6 KB
/
workpool_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
//nolint:gochecknoglobals,funlen
package workpool
import (
"context"
"errors"
"math/rand"
"runtime"
"strconv"
"sync"
"sync/atomic"
"testing"
"time"
"github.com/nextzhou/workpool/wpcore"
. "github.com/smartystreets/goconvey/convey"
)
var (
emptyTask Task = func(ctx context.Context) error { return nil }
blockTask Task = func(ctx context.Context) error {
<-ctx.Done()
return nil
}
)
var panicTask Task = func(ctx context.Context) error {
panic("foo")
}
var errTask Task = func(ctx context.Context) error {
return errors.New("bar") //nolint:goerr113
}
var (
sleepTime = 100 * time.Millisecond
sleepTask Task = func(ctx context.Context) error {
select {
case <-ctx.Done():
case <-time.After(sleepTime):
}
return nil
}
)
var ignoreCtxSleepTask Task = func(ctx context.Context) error {
return sleepTask(context.Background())
}
type taskStat struct {
totalNum int64
currentParallel int64
maxParallel int64
mu sync.Mutex
}
func (s *taskStat) wrap(task Task) Task {
return func(ctx context.Context) error {
parallel := atomic.AddInt64(&s.currentParallel, 1)
s.mu.Lock()
if parallel > s.maxParallel {
s.maxParallel = parallel
}
s.mu.Unlock()
defer func() {
atomic.AddInt64(&s.totalNum, 1)
atomic.AddInt64(&s.currentParallel, -1)
}()
return task(ctx)
}
}
func TestWorkpool(t *testing.T) {
Convey("workpool", t, func() {
Convey("uninitialized workpool", func() {
var w wpcore.Workpool
So(func() { _ = w.Wait() }, ShouldPanic)
})
Convey("reuse workpool", func() {
w := New(context.Background())
So(w.Wait(), ShouldBeNil)
So(func() { _ = w.Wait() }, ShouldPanic)
})
Convey("commonly workpool", func() {
w := New(context.Background())
w.Go(emptyTask)
So(w.Wait(), ShouldBeNil)
})
Convey("take first error", func() {
w := New(context.Background())
for i := 0; i < 10; i++ {
w.Go(func(ctx context.Context) error {
time.Sleep(sleepTime)
return errTask(ctx)
})
}
So(w.Wait(), ShouldBeError, "bar")
})
Convey("panic on Wait goroutine", func() {
w := New(context.Background())
w.Go(panicTask)
So(func() { _ = w.Wait() }, ShouldPanic)
})
Convey("panic on Go goroutine", func() {
w := New(context.Background())
w.Go(panicTask)
time.Sleep(sleepTime)
So(func() { w.Go(emptyTask) }, ShouldPanic)
w = New(context.Background(), Options.SkipPendingTask(false))
w.Go(panicTask)
time.Sleep(sleepTime)
So(func() { w.Go(emptyTask) }, ShouldPanic)
})
Convey("context cancel tasks", func() {
ctx, cancel := context.WithCancel(context.Background())
w := New(ctx)
w.Go(blockTask)
runtime.Gosched()
cancel()
So(w.Wait(), ShouldBeNil)
})
Convey("task error cancel other tasks", func() {
w := New(context.Background())
w.Go(blockTask)
w.Go(errTask)
So(w.Wait(), ShouldBeError, "bar")
})
Convey("collect error", func() {
w := New(context.Background())
w.Go(blockTask)
w.Go(errTask)
w.Go(emptyTask)
So(w.Wait(), ShouldBeError, "bar")
})
Convey("wait all task to finish", func() {
start := time.Now()
w := New(context.Background())
var ts taskStat
w.Go(ts.wrap(ignoreCtxSleepTask))
So(w.Wait(), ShouldBeNil)
So(time.Since(start), ShouldBeGreaterThanOrEqualTo, sleepTime)
So(ts.totalNum, ShouldEqual, 1)
})
Convey("wait all tasks to finish, even if the ctx has already done", func() {
ctx, cancel := context.WithCancel(context.Background())
w := New(ctx)
var ts taskStat
w.Go(ts.wrap(ignoreCtxSleepTask))
w.Go(ts.wrap(ignoreCtxSleepTask))
runtime.Gosched()
cancel()
So(w.Wait(), ShouldBeNil)
So(ts.totalNum, ShouldEqual, 2)
})
Convey("skip pending task error", func() {
ctx, cancel := context.WithCancel(context.Background())
// tasks will not be skipped by default now.
w := New(ctx, Options.SkipPendingTask(true))
w.Go(emptyTask)
runtime.Gosched()
cancel()
w.Go(emptyTask)
So(w.Wait(), ShouldBeError, "skip 1 pending tasks")
})
})
}
func TestOptions_ParallelLimit(t *testing.T) {
rand.Seed(time.Now().UnixNano())
randomParallelNum := uint(rand.Uint32()%10) + 1 //nolint:gosec
Convey("Options.ParallelLimit"+strconv.Itoa(int(randomParallelNum)), t, func() {
var ts taskStat
w := New(context.Background(), Options.ParallelLimit(randomParallelNum))
for i := 0; i < 20; i++ {
w.Go(ts.wrap(ignoreCtxSleepTask))
}
So(w.Wait(), ShouldBeNil)
So(ts.maxParallel, ShouldBeLessThanOrEqualTo, randomParallelNum)
So(ts.currentParallel, ShouldEqual, 0)
So(ts.totalNum, ShouldEqual, 20)
// t.Logf("limit: %d, max: %d\n", randomParallelNum, ts.maxParallel)
})
}
func TestOptions_TaskTimeout(t *testing.T) {
Convey("Options.TaskTimeout", t, func() {
w := New(context.Background(), Options.TaskTimeout(time.Millisecond))
w.Go(blockTask)
So(w.Wait(), ShouldBeNil)
})
}
func TestOptions_Recover(t *testing.T) {
Convey("Options.Recover", t, func() {
Convey("convert panic to error", func() {
var panicErr wpcore.ErrPanic
w := New(context.Background(), Options.Recover(func(err wpcore.ErrPanic) error {
panicErr = err
return errors.New("don't panic") //nolint:goerr113
}))
w.Go(panicTask)
So(w.Wait(), ShouldBeError, "don't panic")
So(panicErr.Recover, ShouldEqual, "foo")
So(panicErr.Error(), ShouldContainSubstring, "foo")
})
Convey("convert panic to ok", func() {
var panicErr wpcore.ErrPanic
w := New(context.Background(), Options.Recover(func(err wpcore.ErrPanic) error {
panicErr = err
return nil
}))
w.Go(panicTask)
So(w.Wait(), ShouldBeNil)
So(panicErr.Recover, ShouldEqual, "foo")
})
Convey("panic in custom recover", func() {
var panicErr wpcore.ErrPanic
w := New(context.Background(), Options.Recover(func(err wpcore.ErrPanic) error {
panicErr = err
panic("panic in custom recover again")
}))
Convey("task panic", func() {
w.Go(panicTask)
So(func() { _ = w.Wait() }, ShouldPanic)
So(panicErr.Recover, ShouldEqual, "foo")
})
Convey("task hasn't panic", func() {
w.Go(emptyTask)
So(w.Wait(), ShouldBeNil)
So(panicErr.Recover, ShouldBeNil)
})
})
})
}
func TestOptions_ExitTogether(t *testing.T) {
Convey("Options.ExitTogether", t, func() {
Convey("single task exit", func() {
w := New(context.Background(), Options.ExitTogether())
start := time.Now()
w.Go(sleepTask)
So(w.Wait(), ShouldBeNil)
So(time.Since(start), ShouldBeGreaterThanOrEqualTo, sleepTime)
})
Convey("non error exit", func() {
w := New(context.Background(), Options.ExitTogether(), Options.IgnoreSkippingPendingErr())
start := time.Now()
w.Go(sleepTask)
w.Go(emptyTask)
So(w.Wait(), ShouldBeNil)
So(time.Since(start), ShouldBeLessThan, sleepTime)
})
Convey("error exit", func() {
w := New(context.Background(), Options.ExitTogether())
start := time.Now()
w.Go(sleepTask)
w.Go(errTask)
So(w.Wait(), ShouldBeError, "bar")
So(time.Since(start), ShouldBeLessThan, sleepTime)
})
Convey("panic exit", func() {
w := New(context.Background(), Options.ExitTogether())
start := time.Now()
w.Go(sleepTask)
w.Go(panicTask)
So(func() { _ = w.Wait() }, ShouldPanic)
So(time.Since(start), ShouldBeLessThan, sleepTime)
})
Convey("panic as error exit", func() {
o := Options
w := New(context.Background(), o.ExitTogether(), o.WrapsChain(Wraps.PanicAsError), o.IgnoreSkippingPendingErr())
start := time.Now()
w.Go(sleepTask)
w.Go(panicTask)
err := w.Wait()
So(err, ShouldBeError)
So(err, ShouldHaveSameTypeAs, wpcore.ErrPanic{})
So(time.Since(start), ShouldBeLessThan, sleepTime)
})
Convey("different error types", func() {
for i := 0; i < 10000; i++ {
w := New(context.Background(), Options.WrapsChain(Wraps.PanicAsError))
w.Go(panicTask)
w.Go(errTask)
_ = w.Wait()
}
})
Convey("ignore panic exit", func() {
w := New(context.Background(), Options.ExitTogether(), Options.Recover(func(err wpcore.ErrPanic) error {
return nil
}))
start := time.Now()
w.Go(sleepTask)
w.Go(panicTask)
So(w.Wait(), ShouldBeNil)
So(time.Since(start), ShouldBeLessThan, sleepTime)
})
})
}
func TestOptions_IgnoreSkippingPendingErr(t *testing.T) {
Convey("Options.IgnoreSkippingPendingErr", t, func() {
Convey("ignore", func() {
ctx, cancel := context.WithCancel(context.Background())
cancel()
w := New(ctx, Options.IgnoreSkippingPendingErr())
var ts taskStat
w.Go(ts.wrap(emptyTask))
So(w.Wait(), ShouldBeNil)
So(ts.totalNum, ShouldEqual, 0)
})
})
}
func TestOptions_WrapsChain(t *testing.T) {
Convey("Options.WrapsChain", t, func() {
var processMarks []int
w1 := wpcore.TaskWrap(func(task Task) Task {
return func(ctx context.Context) error {
processMarks = append(processMarks, 1)
err := task(ctx)
processMarks = append(processMarks, 1)
return err
}
})
w2 := wpcore.TaskWrap(func(task Task) Task {
return func(ctx context.Context) error {
processMarks = append(processMarks, 2)
err := task(ctx)
processMarks = append(processMarks, 2)
return err
}
})
w3 := wpcore.TaskWrap(func(task Task) Task {
return func(ctx context.Context) error {
processMarks = append(processMarks, 3)
err := task(ctx)
processMarks = append(processMarks, 3)
return err
}
})
w := New(context.Background(), Options.WrapsChain(w1, w2, w3))
w.Go(func(context.Context) error {
processMarks = append(processMarks, 0)
return nil
})
So(w.Wait(), ShouldBeNil)
So(processMarks, ShouldResemble, []int{1, 2, 3, 0, 3, 2, 1})
})
}
func TestOptions_DontSkipTask(t *testing.T) {
Convey("Options.DontSkipTask", t, func() {
ctx, cancel := context.WithCancel(context.Background())
cancel()
Convey("skip padding task when ctx done", func() {
// tasks will not be skipped by default now.
wp := New(ctx, Options.SkipPendingTask(true))
wp.Go(emptyTask)
So(wp.Wait(), ShouldBeError, wpcore.ErrSkipPendingTask{SKippingTaskCount: 1})
})
Convey("dont skip any task even though ctx done", func() {
wp := New(ctx, Options.DontSkipTask())
wp.Go(emptyTask)
So(wp.Wait(), ShouldBeNil)
})
})
}
func TestOptions_SkipPendingTask(t *testing.T) {
Convey("Options.SkipPendingTask", t, func() {
Convey("don't ignore", func() {
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
w := New(ctx, Options.SkipPendingTask(true))
var ts taskStat
rand.Seed(time.Now().UnixNano())
cancelIdx := rand.Intn(100) //nolint:gosec
for i := 0; i < 100; i++ {
if i == cancelIdx {
cancel()
}
w.Go(ts.wrap(emptyTask))
}
err := w.Wait()
So(err, ShouldBeError)
var skipErr wpcore.ErrSkipPendingTask
So(errors.As(err, &skipErr), ShouldBeTrue)
So(skipErr.SKippingTaskCount, ShouldEqual, 100-ts.totalNum)
})
Convey("ignore", func() {
ctx, cancel := context.WithCancel(context.Background())
cancel()
w := New(ctx, Options.SkipPendingTask(false))
var ts taskStat
w.Go(ts.wrap(emptyTask))
So(w.Wait(), ShouldBeNil)
So(ts.totalNum, ShouldEqual, 0)
})
})
}
func TestTask_Go(t *testing.T) {
Convey("go single task without pool", t, func() {
Convey("just go", func() {
wait := emptyTask.Go(context.Background())
So(wait, ShouldNotBeNil)
So(wait(), ShouldBeNil)
})
Convey("wait the task done", func() {
start := time.Now()
wait := sleepTask.Go(context.Background())
So(wait(), ShouldBeNil)
So(time.Since(start), ShouldBeGreaterThanOrEqualTo, sleepTime)
})
Convey("context cancel the task", func() {
ctx, cancel := context.WithCancel(context.Background())
wait := blockTask.Go(ctx)
cancel()
So(wait(), ShouldBeNil)
})
Convey("take task error", func() {
wait := errTask.Go(context.Background())
So(wait(), ShouldBeError)
})
Convey("panic on wait function", func() {
wait := panicTask.Go(context.Background())
So(func() { _ = wait() }, ShouldPanic)
})
Convey("panic as error", func() {
task := Wraps.PanicAsError(panicTask)
wait := task.Go(context.Background())
err := wait()
So(err, ShouldBeError)
So(err, ShouldHaveSameTypeAs, wpcore.ErrPanic{})
})
})
}
func TestWraps_PhasedTask(t *testing.T) {
milestone1, milestone2 := "foo", "bar"
Convey("phased task", t, func() {
Convey("milestone", func() {
task, supervisor := Wraps.Phased(func(ctx context.Context, helper wpcore.PhasedTaskHelper) error {
helper.MarkAMilestone(milestone1)
return nil
})
wait := task.Go(context.Background())
milestone, status := supervisor.WaitMilestone(context.Background())
So(status.IsOK(), ShouldBeTrue)
So(milestone, ShouldEqual, milestone1)
So(wait(), ShouldBeNil)
})
Convey("wait a milestone", func() {
task, supervisor := Wraps.Phased(func(ctx context.Context, helper wpcore.PhasedTaskHelper) error {
helper.MarkAMilestone(milestone1)
time.Sleep(sleepTime)
helper.MarkAMilestone(milestone2)
return nil
})
wait := task.Go(context.Background())
milestone, status := supervisor.WaitMilestone(context.Background())
startAt := time.Now()
So(time.Since(startAt), ShouldBeLessThan, sleepTime)
So(status.IsOK(), ShouldBeTrue)
So(milestone, ShouldEqual, milestone1)
ctx, _ := context.WithTimeout(context.Background(), 0) //nolint: govet
milestone, status = supervisor.WaitMilestone(ctx)
So(time.Since(startAt), ShouldBeLessThan, sleepTime)
So(status.IsOK(), ShouldBeFalse)
So(milestone, ShouldBeNil)
So(status.IsContextDone(), ShouldBeTrue)
ctx, _ = context.WithTimeout(context.Background(), 2*sleepTime) //nolint: govet
milestone, status = supervisor.WaitMilestone(ctx)
So(time.Since(startAt), ShouldBeBetween, sleepTime, 2*sleepTime)
So(status.IsOK(), ShouldBeTrue)
So(milestone, ShouldEqual, milestone2)
ctx, _ = context.WithTimeout(context.Background(), sleepTime) //nolint: govet
milestone, status = supervisor.WaitMilestone(ctx)
So(status.IsTaskDone(), ShouldBeTrue)
So(milestone, ShouldBeNil)
So(wait(), ShouldBeNil)
})
Convey("phased task without milestone", func() {
task, supervisor := Wraps.Phased(func(ctx context.Context, helper wpcore.PhasedTaskHelper) error {
return nil
})
task.Go(context.Background())
ctx, _ := context.WithTimeout(context.Background(), sleepTime) //nolint: govet
milestone, status := supervisor.WaitMilestone(ctx)
So(status.IsTaskDone(), ShouldBeTrue)
So(milestone, ShouldBeNil)
})
Convey("cancel task when milestone timeout", func() {
task, supervisor := Wraps.Phased(func(ctx context.Context, helper wpcore.PhasedTaskHelper) error {
helper.MarkAMilestone(milestone1)
<-ctx.Done()
helper.MarkAMilestone(milestone2)
return nil
})
wait := task.Go(context.Background())
ctx, _ := context.WithTimeout(context.Background(), sleepTime) //nolint: govet
milestone, status := supervisor.WaitMilestoneOrCancel(ctx)
So(status.IsOK(), ShouldBeTrue)
So(milestone, ShouldEqual, milestone1)
milestone, status = supervisor.WaitMilestoneOrCancel(ctx)
So(status.IsContextDone(), ShouldBeTrue)
So(milestone, ShouldBeNil)
So(wait(), ShouldBeNil)
})
Convey("skipped phased task", func() {
ctx, cancel := context.WithCancel(context.Background())
cancel()
task, supervisor := wpcore.Phased(func(ctx context.Context, helper wpcore.PhasedTaskHelper) error {
helper.MarkAMilestone(milestone1)
return nil
})
wp := New(ctx, Options.SkipPendingTask(true))
wp.Go(task)
milestone, status := supervisor.WaitMilestone(ctx)
So(milestone, ShouldBeNil)
So(status.IsContextDone(), ShouldBeTrue)
So(status.IsTaskNotRunning(), ShouldBeTrue)
So(wp.Wait(), ShouldBeError, "skip 1 pending tasks")
})
Convey("not-running phased task", func() {
_, supervisor := Wraps.Phased(func(ctx context.Context, helper wpcore.PhasedTaskHelper) error {
helper.MarkAMilestone(milestone1)
return nil
})
ctx, _ := context.WithTimeout(context.Background(), time.Millisecond) //nolint: govet
milestone, status := supervisor.WaitMilestoneOrCancel(ctx)
So(milestone, ShouldBeNil)
So(status.IsContextDone(), ShouldBeTrue)
So(status.IsTaskNotRunning(), ShouldBeTrue)
})
})
}
func TestWraps_RunStopTask(t *testing.T) {
Convey("RunStopTask wrap", t, func() {
var runErr, stopErr error
var runPanic, stopPanic bool
ctx, cancel := context.WithCancel(context.Background())
run := func() error {
if runPanic {
panic("panic at run")
}
<-ctx.Done()
time.Sleep(sleepTime)
return runErr
}
stop := func() error {
if stopPanic {
panic("panic at stop")
}
cancel()
return stopErr
}
task := Wraps.RunStopTask(run, stop)
Convey("stop task, wait `run` done", func() {
ctx, cancel := context.WithTimeout(context.Background(), sleepTime)
defer cancel()
wait := task.Go(ctx)
startAt := time.Now()
So(wait(), ShouldBeNil)
So(time.Since(startAt), ShouldBeGreaterThanOrEqualTo, 2*sleepTime)
})
Convey("`stop` error", func() {
stopErr = errors.New("stop error") //nolint:goerr113
ctx, cancel := context.WithTimeout(context.Background(), sleepTime)
defer cancel()
wait := task.Go(ctx)
So(wait(), ShouldBeError, "stop error")
stopErr = nil
})
Convey("`run` error", func() {
runErr = errors.New("run error") //nolint:goerr113
ctx, cancel := context.WithTimeout(context.Background(), sleepTime)
defer cancel()
wait := task.Go(ctx)
So(wait(), ShouldBeError, "run error")
runErr = nil
})
Convey("panic at `run`", func() {
runPanic = true
ctx, cancel := context.WithTimeout(context.Background(), sleepTime)
defer cancel()
wait := task.Go(ctx)
So(func() { _ = wait() }, ShouldPanic)
runPanic = false
})
Convey("panic at `stop`", func() {
stopPanic = true
ctx, cancel := context.WithTimeout(context.Background(), sleepTime)
defer cancel()
wait := task.Go(ctx)
So(func() { _ = wait() }, ShouldPanic)
stopPanic = false
})
})
}
func BenchmarkGo0(b *testing.B) {
b.ReportAllocs()
wp := New(context.Background())
for i := 0; i < b.N; i++ {
wp.Go(func(ctx context.Context) error {
return nil
})
}
_ = wp.Wait()
}
func BenchmarkGo1(b *testing.B) {
b.ReportAllocs()
wp := New(context.Background(), Options.ParallelLimit(1))
for i := 0; i < b.N; i++ {
wp.Go(emptyTask)
}
_ = wp.Wait()
}
func BenchmarkGo10(b *testing.B) {
b.ReportAllocs()
wp := New(context.Background(), Options.ParallelLimit(10))
for i := 0; i < b.N; i++ {
wp.Go(emptyTask)
}
_ = wp.Wait()
}
func BenchmarkGo100(b *testing.B) {
b.ReportAllocs()
wp := New(context.Background(), Options.ParallelLimit(100))
for i := 0; i < b.N; i++ {
wp.Go(emptyTask)
}
_ = wp.Wait()
}
func BenchmarkGo1000(b *testing.B) {
b.ReportAllocs()
wp := New(context.Background(), Options.ParallelLimit(1000))
for i := 0; i < b.N; i++ {
wp.Go(emptyTask)
}
_ = wp.Wait()
}