Reduce integration test overhead (#32475)
In profiling integration tests, I found a couple places where per-test overhead could be reduced: * Avoiding disk IO by synchronizing instead of deleting & copying test Git repository data. This saves ~100ms per test on my machine * When flushing queues in `PrintCurrentTest`, invoke `FlushWithContext` in a parallel. --------- Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
This commit is contained in:
parent
249e67672a
commit
68731c07c5
102 changed files with 104 additions and 465 deletions
|
@ -197,15 +197,30 @@ func (q *WorkerPoolQueue[T]) doFlush(wg *workerGroup[T], flush flushType) {
|
|||
defer log.Debug("Queue %q finishes flushing", q.GetName())
|
||||
|
||||
// stop all workers, and prepare a new worker context to start new workers
|
||||
|
||||
wg.ctxWorkerCancel()
|
||||
wg.wg.Wait()
|
||||
|
||||
defer func() {
|
||||
close(flush)
|
||||
close(flush.c)
|
||||
wg.doPrepareWorkerContext()
|
||||
}()
|
||||
|
||||
if flush.timeout < 0 {
|
||||
// discard everything
|
||||
wg.batchBuffer = nil
|
||||
for {
|
||||
select {
|
||||
case <-wg.popItemChan:
|
||||
case <-wg.popItemErr:
|
||||
case <-q.batchChan:
|
||||
case <-q.ctxRun.Done():
|
||||
return
|
||||
default:
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// drain the batch channel first
|
||||
loop:
|
||||
for {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue