[#1450] engine: Batch addresses in (*StorageEngine).Inhume
All checks were successful
Tests and linters / Run gofumpt (pull_request) Successful in 1m21s
DCO action / DCO (pull_request) Successful in 1m47s
Vulncheck / Vulncheck (pull_request) Successful in 2m18s
Pre-commit hooks / Pre-commit (pull_request) Successful in 2m24s
Build / Build Components (pull_request) Successful in 2m44s
Tests and linters / gopls check (pull_request) Successful in 3m0s
Tests and linters / Staticcheck (pull_request) Successful in 3m11s
Tests and linters / Lint (pull_request) Successful in 3m57s
Tests and linters / Tests (pull_request) Successful in 4m39s
Tests and linters / Tests with -race (pull_request) Successful in 6m6s
All checks were successful
Tests and linters / Run gofumpt (pull_request) Successful in 1m21s
DCO action / DCO (pull_request) Successful in 1m47s
Vulncheck / Vulncheck (pull_request) Successful in 2m18s
Pre-commit hooks / Pre-commit (pull_request) Successful in 2m24s
Build / Build Components (pull_request) Successful in 2m44s
Tests and linters / gopls check (pull_request) Successful in 3m0s
Tests and linters / Staticcheck (pull_request) Successful in 3m11s
Tests and linters / Lint (pull_request) Successful in 3m57s
Tests and linters / Tests (pull_request) Successful in 4m39s
Tests and linters / Tests with -race (pull_request) Successful in 6m6s
Signed-off-by: Aleksey Savchuk <a.savchuk@yadro.com>
This commit is contained in:
parent
b12968e959
commit
6f0519ec6a
1 changed files with 25 additions and 2 deletions
|
@ -17,6 +17,7 @@ import (
|
|||
"go.opentelemetry.io/otel/attribute"
|
||||
"go.opentelemetry.io/otel/trace"
|
||||
"go.uber.org/zap"
|
||||
"golang.org/x/sync/errgroup"
|
||||
)
|
||||
|
||||
// InhumePrm encapsulates parameters for inhume operation.
|
||||
|
@ -72,8 +73,30 @@ func (e *StorageEngine) Inhume(ctx context.Context, prm InhumePrm) (res InhumeRe
|
|||
defer span.End()
|
||||
|
||||
err = e.execIfNotBlocked(func() error {
|
||||
res, err = e.inhume(ctx, prm)
|
||||
return err
|
||||
groupSize := 100
|
||||
totalSize := len(prm.addrs)
|
||||
batchSize := max(totalSize/groupSize, 1)
|
||||
|
||||
g := errgroup.Group{}
|
||||
g.SetLimit(groupSize)
|
||||
|
||||
for batchBase := 0; batchBase < totalSize; batchBase += batchSize {
|
||||
batchPrm := InhumePrm{
|
||||
tombstone: prm.tombstone,
|
||||
// TODO: write tests with different number of address,
|
||||
// especially when
|
||||
// (totalSize > groupSize) and (totalSize % groupSize != 0)
|
||||
addrs: prm.addrs[batchBase:min(batchBase+batchSize, totalSize)],
|
||||
forceRemoval: prm.forceRemoval,
|
||||
}
|
||||
|
||||
g.Go(func() error {
|
||||
_, err = e.inhume(ctx, batchPrm)
|
||||
return err
|
||||
})
|
||||
}
|
||||
|
||||
return g.Wait()
|
||||
})
|
||||
|
||||
return
|
||||
|
|
Loading…
Reference in a new issue