qpid-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "ASF GitHub Bot (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (QPIDJMS-461) JmsMessageIDBuilder::createMessageID can save StringBuilder allocations
Date Tue, 18 Jun 2019 09:25:00 GMT

    [ https://issues.apache.org/jira/browse/QPIDJMS-461?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16866389#comment-16866389
] 

ASF GitHub Bot commented on QPIDJMS-461:
----------------------------------------

gemmellr commented on pull request #30: QPIDJMS-461 Optimize the default message ID builder
URL: https://github.com/apache/qpid-jms/pull/30#discussion_r294693257
 
 

 ##########
 File path: qpid-jms-client/src/main/java/org/apache/qpid/jms/message/JmsMessageIDBuilder.java
 ##########
 @@ -30,15 +30,34 @@
         DEFAULT {
             @Override
             public JmsMessageIDBuilder createBuilder() {
+
+                /**
+                 * The default builder is meant to be used as a single instance per producer
+                 * and will yield incorrect results if used across multiple producer instances.
+                 */
                 return new JmsMessageIDBuilder() {
 
+                    private final StringBuilder builder = new StringBuilder();
+                    private int idPrefixLength = 0;
+
                     @Override
                     public Object createMessageID(String producerId, long messageSequence)
{
-                        String messageId = producerId + "-" + messageSequence;
-                        if (!AmqpMessageIdHelper.hasMessageIdPrefix(messageId)) {
-                            messageId = AmqpMessageIdHelper.JMS_ID_PREFIX + messageId;
+                        builder.setLength(idPrefixLength);
 
 Review comment:
   Should perhaps verify that it was actually initialised, and if not then throw or do so
now?
 
----------------------------------------------------------------
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:
users@infra.apache.org


> JmsMessageIDBuilder::createMessageID can save StringBuilder allocations
> -----------------------------------------------------------------------
>
>                 Key: QPIDJMS-461
>                 URL: https://issues.apache.org/jira/browse/QPIDJMS-461
>             Project: Qpid JMS
>          Issue Type: Improvement
>    Affects Versions: 0.44.0
>            Reporter: Francesco Nigro
>            Priority: Minor
>         Attachments: screenshot-1.png
>
>
> JmsMessageIDBuilder::createMessageID doesn't seem able to correctly perform escape analysis
on StringBuilder, allocating many of them.
> The intermediate StringBuilder could be saved into a thread local pool instead, saving
unnececessary allocations.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@qpid.apache.org
For additional commands, e-mail: dev-help@qpid.apache.org


Mime
View raw message