Skip to content

Commit

Permalink
perf(storagenode): estimate the number of batchlets
Browse files Browse the repository at this point in the history
This PR estimates the number of batchlets more accurately. Previously, the number of batchlets is
estimated by dividing the size of batches by the smallest batchlet. It is now divided by the right
size of batchlet.
  • Loading branch information
ijsong committed Apr 13, 2023
1 parent 467ee59 commit a329065
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions internal/storagenode/logstream/append.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,16 @@ func (lse *Executor) Append(ctx context.Context, dataBatch [][]byte) ([]snpb.App
startTime := time.Now()
var preparationDuration time.Duration
dataBatchLen := len(dataBatch)

_, batchletLen := batchlet.SelectLengthClass(dataBatchLen)
batchletCount := dataBatchLen / batchletLen
if dataBatchLen%batchletLen > 0 {
batchletCount++
}

apc := appendContext{
sts: make([]*sequenceTask, 0, dataBatchLen/batchlet.LengthClasses[0]),
wwgs: make([]*writeWaitGroup, 0, dataBatchLen/batchlet.LengthClasses[0]),
sts: make([]*sequenceTask, 0, batchletCount),
wwgs: make([]*writeWaitGroup, 0, batchletCount),
awgs: make([]*appendWaitGroup, 0, dataBatchLen),
}

Expand Down

0 comments on commit a329065

Please sign in to comment.