-
1. Re: How to activate write-behind in file local cache store
domak Feb 13, 2012 2:00 PM (in response to domak)I've found how to enable... I've forgot the enable() after async() (it will be good to have toString() methods implemented on Configuration objects):
Configuration config = new ConfigurationBuilder().loaders().shared(false).passivation(false).preload(false).addFileCacheStore() .location(CACHE_DIR).async().enable().threadPoolSize(10).eviction().maxEntries(100000).build();
I see a separate thread (AsyncProcessor) that write entries in the FileStore.
But the test is worst (80 seconds instead 70) cause main thread spend a lot of time (30% of CPU time) in FileCacheStore.flush().
Here a call tree extract from main thread:
org.infinispan.commands.write.PutKeyValueCommand.acceptVisitor(InvocationContext, Visitor),"2796" org.infinispan.interceptors.CacheLoaderInterceptor.visitPutKeyValueCommand(InvocationContext, PutKeyValueCommand),"2796"
org.infinispan.interceptors.CacheLoaderInterceptor.loadIfNeeded(InvocationContext, Object, boolean, FlagAffectedCommand),"2734"
org.infinispan.loaders.decorators.AbstractDelegatingStore.load(Object),"2734"
org.infinispan.loaders.LockSupportCacheStore.load(Object),"2734"
org.infinispan.loaders.bucket.BucketBasedCacheStore.loadLockSafe(Object, Object),"2687"
org.infinispan.loaders.bucket.BucketBasedCacheStore.loadLockSafe(Object, Integer),"2687"
org.infinispan.loaders.file.FileCacheStore.loadBucket(Integer),"2687"
org.infinispan.loaders.file.FileCacheStore.loadBucket(File),"2640"
org.infinispan.loaders.file.FileCacheStore$BufferedFileSync.flush(File),"2343"
sun.nio.ch.FileChannelImpl.force(boolean),"2343"
Any idea?
-
2. Re: How to activate write-behind in file local cache store
domak Feb 14, 2012 5:19 AM (in response to domak)I finally found the performance problem. The put() operation loads the entry from cache to return the old value. This force a read from file and the flush that coast so much in my test.
In my case, I don't need that old value.
I've found that method:
org.infinispan.interceptors.CacheLoaderInterceptor.loadIfNeeded(InvocationContext, Object, boolean, FlagAffectedCommand)
method use a flag to disable this read: SKIP_CACHE_STORE
I was not able to find how to configure the cache to enable that but this page explains how to disable the read on a put() operation:
cache.getAdvancedCache().withFlags(Flag.SKIP_CACHE_LOAD).put(id, randomUUID);
with this option, my 10 000 entries are put on the cache in 700ms instead of 70-80 seconds!
-
3. Re: How to activate write-behind in file local cache store
sannegrinovero Feb 14, 2012 9:04 AM (in response to domak)Hi Christophe,
yes that's correct: sorry for the late response, but glad you found the solution.
There are more Flags which provide similar options, make sure you know about all of them; I've added a link from the page you had already found.
-
4. Re: How to activate write-behind in file local cache store
domak Feb 14, 2012 9:35 AM (in response to sannegrinovero)Thank, I was filling an enhancement ticket to have SKIP_LOAD_CACHE with configuration but you wrote a sample of how to do this with decorated cache.
I added a comment in the following page : https://docs.jboss.org/author/display/ISPN/Configuring+cache+programmatically because enable() is missing after async() in the sample.
I also filled a ticket (https://issues.jboss.org/browse/ISPN-1861) to have a toString() method in configuration objects. It should have help me to discover that write-behind was not enabled.