From 3c91b6214a058fa5850885d13f550a23c2ddde8c Mon Sep 17 00:00:00 2001 From: Injun Song Date: Tue, 11 Apr 2023 16:58:41 +0900 Subject: [PATCH] perf(storagenode): estimate the number of batchlets 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. --- internal/storagenode/logstream/append.go | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/internal/storagenode/logstream/append.go b/internal/storagenode/logstream/append.go index 40ca41aa0..d7f94b3db 100644 --- a/internal/storagenode/logstream/append.go +++ b/internal/storagenode/logstream/append.go @@ -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), }