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

ASF subversion and git services commented on AMQ-9721:
------------------------------------------------------

Commit 5a3abbc877bff6d73c2ab6cecec81d50dd18c839 in activemq's branch 
refs/heads/main from Christopher L. Shannon
[ https://gitbox.apache.org/repos/asf?p=activemq.git;h=5a3abbc877 ]

AMQ-9721 - Fix performance issues during non-persistent cursor removal (#1447)

This fixes the broker so multiple removals are no longer done for the
same message leading to having to search the entire non persistent
pending list. Durable subscriptions now check the persistence type of
the message so the cursor will no longer search everything in a
non-persistent pending list when the message is persistent.

> Fix performance issues with non-persistent message removal from topic/durable 
> subscriptions
> -------------------------------------------------------------------------------------------
>
>                 Key: AMQ-9721
>                 URL: https://issues.apache.org/jira/browse/AMQ-9721
>             Project: ActiveMQ Classic
>          Issue Type: Bug
>    Affects Versions: 6.1.6, 5.18.7
>            Reporter: Christopher L. Shannon
>            Assignee: Christopher L. Shannon
>            Priority: Major
>             Fix For: 6.2.0, 5.19.1, 6.1.7
>
>          Time Spent: 0.5h
>  Remaining Estimate: 0h
>
> While testing various scenarios with expiration on subscriptions I noticed 
> that when there is a large backlog of non-persistent messages the CPU usage 
> would spike in some cases for removing messages. This only happened when non 
> persistent messages were using the pending disk list and not in memory.
> After investigation, it turns out there are a couple of problems that need to 
> be resolved.
> # FilePendingMessageCursor flushes messages to disk when memory is full. The 
> disk cursor uses a linked list as an index which has O\(n) performance for 
> random access. This is not an issue because the broker is going to append 
> messages to the front/end and then page them in from the front for dispatch, 
> expire, discard, etc. Except...it turns out in a couple spots the broker is 
> actually incorrectly calling remove twice on the cursor for the same message. 
> (Happens on discard for topic subs, also during expiration for durable subs). 
> Usually when remove is called it finds the message pretty quickly as it was 
> recently dispatched or paged in, except since it's called twice it iterates 
> over the entire linked list for no reason and finds nothing. This causes a 
> huge performance problem if there's a large backup (ie millions)
> # The second problem is specific to durable subscriptions. The durable sub 
> cursor contains a list of cursors for its topic stores and also for it's 
> non-persistent cursor. The problem is that when the expiration task runs and 
> calls the remove method, it is being delegated to all cursors, including non 
> persistent. So even though it will never find the message in the cursor if 
> there's a huge non-persistent backlog it causes a lot of CPU usage to search. 
> This can be fixed by checking the persistent type and only calling the right 
> prefetches for remove, similar to how the add method works and how queue 
> subscriptions work.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
For further information, visit: https://activemq.apache.org/contact


Reply via email to