You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@skywalking.apache.org by GitBox <gi...@apache.org> on 2021/06/30 02:31:08 UTC

[GitHub] [skywalking] wu-sheng commented on a change in pull request #7204: Fix the queue initial size is not set by max batch size accordingly

wu-sheng commented on a change in pull request #7204:
URL: https://github.com/apache/skywalking/pull/7204#discussion_r661085613



##########
File path: oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/storage/PersistenceTimer.java
##########
@@ -203,16 +203,18 @@ private void extractDataAndSave(IBatchDAO batchDAO) {
         }
     }
 
-    @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 * 2 as the initial queue size to avoid ArrayList#grow
+            this.elementData = new ArrayList<>(maxBatchSize * 3);

Review comment:
       Wrong comments, it was `*3`, but hardcoded `maxBatchSize`




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@skywalking.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org