[ 
https://issues.apache.org/jira/browse/ARTEMIS-3133?focusedWorklogId=560844&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-560844
 ]

ASF GitHub Bot logged work on ARTEMIS-3133:
-------------------------------------------

                Author: ASF GitHub Bot
            Created on: 04/Mar/21 06:33
            Start Date: 04/Mar/21 06:33
    Worklog Time Spent: 10m 
      Work Description: franz1981 commented on a change in pull request #3475:
URL: https://github.com/apache/activemq-artemis/pull/3475#discussion_r587190763



##########
File path: 
artemis-commons/src/main/java/org/apache/activemq/artemis/utils/ObjectPool.java
##########
@@ -0,0 +1,70 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.activemq.artemis.utils;
+
+import java.util.Queue;
+import java.util.function.Consumer;
+import java.util.function.Supplier;
+
+import io.netty.util.internal.PlatformDependent;
+
+/**
+ * A simple encapsulation of Netty MpscQueue to provide a pool of objects.
+ * @param <T>
+ */
+public class ObjectPool<T> {
+
+   private final Queue<T> internalPool;
+
+   private final Consumer<T> cleaner;
+   private final Supplier<T> supplier;
+
+   public ObjectPool(int maxSize, Consumer<T> cleaner, Supplier<T> supplier) {
+      if (maxSize > 0) {
+         internalPool = PlatformDependent.newFixedMpscQueue(maxSize);

Review comment:
       In short:
   - If you still want to create the utility I would use different factory 
methods and config parameters to cover all the use cases (spsc, mpmc,mpsc,spmc) 
but probably there are not enouf JCTools queues and just using mpmc is not a 
good idea because the performance and memory footprint are not negligible
   - I wouldn't create any object pool in case is not needed, to save 
additional methods in the stack, lambdas and creation checks




----------------------------------------------------------------
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.

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


Issue Time Tracking
-------------------

    Worklog Id:     (was: 560844)
    Time Spent: 3h 50m  (was: 3h 40m)

> Reduce memory usage for Null an Ping packets
> --------------------------------------------
>
>                 Key: ARTEMIS-3133
>                 URL: https://issues.apache.org/jira/browse/ARTEMIS-3133
>             Project: ActiveMQ Artemis
>          Issue Type: Improvement
>            Reporter: Francesco Nigro
>            Assignee: Francesco Nigro
>            Priority: Major
>          Time Spent: 3h 50m
>  Remaining Estimate: 0h
>
> Currently NullResponseMessage and Ping report a wrong expected size (== 
> 1500): it means that the allocated Netty buffers will be much bigger then 
> necessary eg null is 13 bytes, while null v2 is 21.
>  
> In addition, NullReponseMessage could be cached if the transport channel 
> won't use any resend cache, greatly reducing the memory used under load.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to