Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

restore: use a limited workpool #51872

Merged
merged 3 commits into from
Mar 26, 2024
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion br/pkg/restore/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -667,6 +667,16 @@ func (rc *Client) GetFilesInRawRange(startKey []byte, endKey []byte, cf string)
// SetConcurrency sets the concurrency of dbs tables files.
func (rc *Client) SetConcurrency(c uint) {
log.Info("download worker pool", zap.Uint("size", c))
if rc.granularity == string(CoarseGrained) {
// we believe 32 is large enough for download worker pool.
// it won't reach the limit if sst files distribute evenly.
// when restore memory usage is still too high, we should reduce concurrencyPerStore
// to sarifice some speed to reduce memory usage.
count := uint(rc.storeCount) * rc.concurrencyPerStore * 32
log.Info("download coarse worker pool", zap.Uint("size", count))
rc.workerPool = utils.NewWorkerPool(count, "file")
return
}
rc.workerPool = utils.NewWorkerPool(c, "file")
}

Expand Down Expand Up @@ -1544,8 +1554,8 @@ LOOPFORTABLE:
// wait for download worker notified
rc.fileImporter.cond.Wait()
}
eg.Go(restoreFn)
rc.fileImporter.cond.L.Unlock()
rc.workerPool.ApplyOnErrorGroup(eg, restoreFn)
} else {
// if we are not use coarse granularity which means
// we still pipeline split & scatter regions and import sst files
Expand Down
Loading