You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@activemq.apache.org by "Clebert Suconic (Jira)" <ji...@apache.org> on 2021/08/25 17:14:00 UTC

[jira] [Commented] (ARTEMIS-3444) Paging cache entries are not evicted although eligible for GC

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

Clebert Suconic commented on ARTEMIS-3444:
------------------------------------------

The way it's currently implemented they are not supposed to.

These SoftRefereces are supposed to stay in place for a given address.. and we remove them and when add another page.

The softReferences are supposed to clear things before major events such as Out of Memory Exception.


WeakReferences are too weak for this... hence I had used SoftValueHashMap years ago.

We should revisit the caching on paging for a next major version... but this is behaving as designed at this point.

> Paging cache entries are not evicted although eligible for GC
> -------------------------------------------------------------
>
>                 Key: ARTEMIS-3444
>                 URL: https://issues.apache.org/jira/browse/ARTEMIS-3444
>             Project: ActiveMQ Artemis
>          Issue Type: Improvement
>            Reporter: Francesco Nigro
>            Assignee: Francesco Nigro
>            Priority: Minor
>
> Artemis Paging cache is using {{SoftValueLongObjectHashMap}} to collect page cache entries, that's using a [ReferenceQueue|https://docs.oracle.com/javase/8/docs/api/java/lang/ref/ReferenceQueue.html] to track values eligible for GC.
> Soft references become eligible to be collected by JVM according to {{-XX:SoftRefLRUPolicyMSPerMB}} configuration and it affects when broker can remove such entries from the mentioned {{SoftValueLongObjectHashMap}} too, after offering them in the mentioned [ReferenceQueue|https://docs.oracle.com/javase/8/docs/api/java/lang/ref/ReferenceQueue.html].
> The mechanism that allow broker to remove any pending memory is by processing the ref queue filled by the JVM, but it is triggered just if there's any interaction with the page cache (size/put/remove/get/iteration), meaning that if there are no interactions, the broker won't remove such entries and the related reference queue will grow larger and larger, further occupying memory (and likely GC resources).
> The paging cache should be able to remove such entries as soon as the JVM enqueue them on the map ref queue, instead and this could be achieved by allowing background processing of evicted soft refs.
>  
> Given that [ReferenceQueue|https://docs.oracle.com/javase/8/docs/api/java/lang/ref/ReferenceQueue.html] expose timed thread-safe remove methods that could be called in background, we can considerusing a scheduled executor to monitor to remove evicted entries.
> It's key to manage concurrency of such remove operations while interacting with the map
> ie map put has created a soft ref that's immediately offered to the ref q and it's going to be removed *before* put complete, risking to "resurrect" it.
> An additional optimization could be to use a single shared reference queue, to allow using a single thread to perform the removal and (hence having the chance to issue parallel map removal requests for to the related {{PageCursorProviderImpl}}).



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