]
Dmitry Katsubo commented on ISPN-9023:
--------------------------------------
I have attached the simple [^test.7z]. When running {{mvn test}} the output should be
similar to:
{code}
12:05:32.653 [main] INFO GlobalComponentRegistry - ISPN000128: Infinispan version:
Infinispan 'Bastille' 9.1.1.Final
12:05:33.102 [main] INFO ISPN_9023_Test - Finished the test with configuration file
infinispan_COUNT.xml and ratio 75%.
12:05:33.198 [main] INFO ISPN_9023_Test - Finished the test with configuration file
infinispan_OFFHEAP.xml and ratio 75%.
12:05:33.304 [main] INFO ISPN_9023_Test - Finished the test with configuration file
infinispan_MEMORY.xml and ratio 43%.
{code}
It is expected that last test against {{MEMORY}} ends with hit ratio 75%.
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
Attachments: test.7z
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-ty...].
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.