[infinispan-issues] [JBoss JIRA] (ISPN-9023) Eviction profile for “memory” type is different from “count” type
William Burns (JIRA)
issues at jboss.org
Thu Mar 29 10:46:01 EDT 2018
[ https://issues.jboss.org/browse/ISPN-9023?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13554111#comment-13554111 ]
William Burns commented on ISPN-9023:
-------------------------------------
COUNT and MEMORY (when using binary or object storage) both use the same eviction algorithm under the covers (which is controlled by Caffeine). The only mode that doesn't use Caffeine is when using off heap storage in which case we use a simple LRU cache.
>From the sound of it you are running into something regarding weights affecting which entries it evicts. Are you able to write a simple reproducer? If so Ben Manes who wrote Caffeine should be able to help figure out what is going on exactly, as he mentioned on the forum post.
> Eviction profile for “memory” type is different from “count” type
> -----------------------------------------------------------------
>
> Key: ISPN-9023
> URL: https://issues.jboss.org/browse/ISPN-9023
> Project: Infinispan
> Issue Type: Bug
> Components: Eviction
> Affects Versions: 9.1.1.Final
> Environment: * Sun JDK 8 (1.8.0_92)
> * Linux x64
> Reporter: Dmitry Katsubo
> Priority: Minor
>
> I would like to use Infinispan as cache for image binary data (Java type {{byte[]}}). I assume that Infinispan default strategy is LIFO or similar strategy that prefers to keep most recently used/added cache entity.
> In my loadtest scenario I make four calls in the round to retrieve the same entity. It is assumed that first call never hits the cache (because each round a unique entity is requested), but following three always hit the cache. So the expected profile should look like this:
> {code}
> #1: MISS-HIT-HIT-HIT
> #2: MISS-HIT-HIT-HIT
> ...
> {code}
> It works perfectly (exactly as expected above) when I configure Infinispan with COUNT eviction type with some number of entities:
> {code}
> <local-cache name="imagesCache" statistics="true">
> <!-- lifespan="30 min" max-idle="30 min" interval="1 min" -->
> <expiration lifespan="1800000" max-idle="1800000" interval="60000" />
> <memory>
> <binary eviction="COUNT" size="500" />
> </memory>
> </local-cache>
> {code}
> Cache hit ratio based on numbers I capture in loadtest: {{(2952-738)/2952 = 0.75}} and that matches the stats I observe via JMX.
> When I change the number of entities to keep in the memory (<binary eviction="COUNT" size="100" />), hit ratio does not change (as expected).
> After that I have restarted the application with only this small change in cache configuration:
> {code}
> <memory>
> <binary eviction="MEMORY" size="1000000" />
> </memory>
> {code}
> I would expect that Infinispan performance has the same profile, however it turns out that once the given amount of memory is fully allocated, newly added entities don't evict old entities but get immediately evicted. It means that roughly after 100 entities are added, all four requests to cache result cache miss (the ratio is now 0.58 instead of 0.75):
> {code}
> #1: MISS-HIT-HIT-HIT
> #2: MISS-HIT-HIT-HIT
> ...
> #101: MISS-MISS-MISS-MISS
> ...
> {code}
> If I increase the memory, indeed hit ratio comes closer to 0.75 however I would like hit ratio to be the same irrespective the memory size (provided that memory can fit at least few entities).
> Once I configure the passivation to file, memory-based eviction policy starts to work as expected:
> {code}
> <local-cache name="imagesCache" statistics="true">
> <expiration lifespan="1800000" max-idle="1800000" interval="60000" />
> <persistence passivation="true">
> <file-store path="/var/cache/infinispan" purge="true">
> <write-behind thread-pool-size="5" />
> </file-store>
> </persistence>
> <memory>
> <binary eviction="MEMORY" size="1000000" />
> </memory>
> </local-cache>
> {code}
> but I would like to force the profile I need without passivation enabled.
> Additional information is provided [on the forum|https://stackoverflow.com/questions/48420712/eviction-for-memory-type-is-different-from-count-type].
> Bottomline: If underlying component supports different eviction "modes", please expose this setting via XML so that the user of the library can control the mode.
--
This message was sent by Atlassian JIRA
(v7.5.0#75005)
More information about the infinispan-issues
mailing list