Fix the queue initial size is not set by max batch size accordingly (#7204)

This commit is contained in:
吴晟 Wu Sheng 2021-06-30 11:33:07 +08:00 committed by GitHub
parent 16ebaade6a
commit 89549c0183
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 5 deletions

View File

@ -29,7 +29,6 @@ import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.skywalking.apm.util.RunnableWithExceptionProtection;
import org.apache.skywalking.oap.server.core.CoreModuleConfig;
@ -203,16 +202,18 @@ public enum PersistenceTimer {
}
}
@RequiredArgsConstructor
static class DefaultBlockingBatchQueue<E> implements BlockingBatchQueue<E> {
@Getter
private final int maxBatchSize;
private final List<E> elementData;
@Getter
private boolean inAppendingMode = true;
private final List<E> elementData = new ArrayList<>(50000 * 3);
public DefaultBlockingBatchQueue(final int maxBatchSize) {
this.maxBatchSize = maxBatchSize;
// Use the maxBatchSize * 3 as the initial queue size to avoid ArrayList#grow
this.elementData = new ArrayList<>(maxBatchSize * 3);
}
@Override
public void offer(List<E> elements) {