mattrpav opened a new pull request, #2149:
URL: https://github.com/apache/activemq/pull/2149
…kip O(n) expiry scan TopicSubscription
When a slow-consumer's pending-message buffer exceeds the high-water mark
(default: 1000 messages), TopicSubscription.add() calls removeExpiredMessages()
on every single message add. That method iterates every pending message and
calls isExpired(), which is an O(n) scan over the full buffer. When messages
carry no TTL (isExpired() always returns false), this scan provides no benefit
-- it iterates the entire buffer on every add with zero messages removed. With
a large pending limit (e.g. 20,000), this adds up to millions of no-op
iterations per second on busy topics. This commit adds an expiryCheckEnabled
boolean (default true) to MessageEvictionStrategy. Setting it to false inserts
a single guard in TopicSubscription.add():
if (expiryCheckEnabled && !matched.isEmpty() && matched.size() > max) {
removeExpiredMessages();
}
Also adds:
- TopicSubscriptionEnableExpiryTest: 11 correctness/propagation/integration
tests
- TopicSubscriptionEnableExpiryThroughputTest: throughput comparison test
(cherry picked from commit f166435d31d6e9d856d8996741ca9feeaeb8ccb2)
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
For further information, visit: https://activemq.apache.org/contact