[
https://issues.apache.org/jira/browse/ARTEMIS-3444?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Francesco Nigro updated ARTEMIS-3444:
-------------------------------------
Description:
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 GC has offered 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
should consider using a scheduled executor to monitor & 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.
was:
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 GC has offered 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.
> 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 GC has offered 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 should consider using a scheduled executor to monitor & 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.
--
This message was sent by Atlassian Jira
(v8.3.4#803005)