[
https://issues.apache.org/jira/browse/ARTEMIS-2170?focusedWorklogId=187828&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-187828
]
ASF GitHub Bot logged work on ARTEMIS-2170:
-------------------------------------------
Author: ASF GitHub Bot
Created on: 21/Jan/19 16:12
Start Date: 21/Jan/19 16:12
Worklog Time Spent: 10m
Work Description: michaelandrepearce commented on issue #2427:
ARTEMIS-2170 Optimized CoreMessage's checkProperties and
cleanupInternalProperties methods
URL: https://github.com/apache/activemq-artemis/pull/2427#issuecomment-456125516
e.g.
if you simply make a small change on master so you can get a callback, to
see if its entering the if, and iterating, so you can test....
e.g.
`
public void cleanupInternalProperties(Consumer<Set<SimpleString>>
consumer) {
if (properties.hasInternalProperties()) {
LinkedList<SimpleString> valuesToRemove = null;
if (consumer != null) {
consumer.accept(getPropertyNames());
}
for (SimpleString name : getPropertyNames()) {
// We use properties to establish routing context on clustering.
// However if the client resends the message after receiving, it
needs to be removed
if ((name.startsWith(Message.HDR_ROUTE_TO_IDS) &&
!name.equals(Message.HDR_ROUTE_TO_IDS)) ||
(name.startsWith(Message.HDR_ROUTE_TO_ACK_IDS) &&
!name.equals(Message.HDR_ROUTE_TO_ACK_IDS))) {
if (valuesToRemove == null) {
valuesToRemove = new LinkedList<>();
}
valuesToRemove.add(name);
}
}
if (valuesToRemove != null) {
for (SimpleString removal : valuesToRemove) {
this.removeProperty(removal);
}
}
}
}
`
Then run a little simple main, you can quickly see it only enters the
iterating if an internal property was set.
` //This shows that we only iterate if an internal property has been set,
// even if that itself is not optimised it shows that if no internal
properties we avoid iterating.
public static void main(String... args) {
CoreMessage coreMessage = new CoreMessage();
coreMessage.checkProperties();
System.out.println("test one check empty we dont iterate");
//We should not see i got called.
coreMessage.cleanupInternalProperties((s) -> System.out.println("i
should NOT have been called"));
System.out.println("test two, check on not using an internal
property we dont iterate");
coreMessage.putStringProperty("ABC", "a");
//We should not see i got called.
coreMessage.cleanupInternalProperties((s) -> System.out.println("i
should NOT have been called"));
System.out.println("test three, on setting an internal property,
even if not one we want to remove, we iterate");
coreMessage.putStringProperty(HDR_ROUTE_TO_IDS, "a");
//We NOW should see i got called.
coreMessage.cleanupInternalProperties((s) -> System.out.println("i
should be called"));
}`
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
Issue Time Tracking
-------------------
Worklog Id: (was: 187828)
Time Spent: 2.5h (was: 2h 20m)
> Optimized CoreMessage's checkProperties and cleanupInternalProperties methods
> -----------------------------------------------------------------------------
>
> Key: ARTEMIS-2170
> URL: https://issues.apache.org/jira/browse/ARTEMIS-2170
> Project: ActiveMQ Artemis
> Issue Type: Improvement
> Components: Broker
> Reporter: Francesco Nigro
> Assignee: Francesco Nigro
> Priority: Minor
> Time Spent: 2.5h
> Remaining Estimate: 0h
>
> CoreMessage::checkProperties perform too many volatile read/write and has a
> too big body just to handle exceptional cases, while
> cleanupInternalProperties is called on the hot path of session send, but is
> performing too many synchronized operations and loopup on TypedProperties.
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)