Hi,

I use the following code to find the maximum speed of a read-through cache.
I use 

cacheCfg.setExpiryPolicyFactory(AccessedExpiryPolicy.factoryOf(Duration.ZERO));
and the load function just returns null:

public static class NullCache extends CacheStoreAdapter<Long, Long> {
        @Override public Long load(Long key) { return null; /* MAX PERFORMANCE 
*/ }
        @Override public void write(Cache.Entry<? extends Long, ? extends Long>
entry) {}
        @Override public void delete(Object key) { }
        @Override public void loadCache(IgniteBiInClosure<Long, Long> clo,
Object... args) { }
}
public static void testReadPerformance() {
        IgniteConfiguration cfg = new IgniteConfiguration();
        Ignite ignite = Ignition.start(cfg);
        final long itemCount = 1000000;
        for (int readThrough = 0; readThrough <= 1; readThrough++) {
                CacheConfiguration<Long, Long> cacheCfg = new 
CacheConfiguration<>();
                cacheCfg.setCacheMode(CacheMode.LOCAL);
                cacheCfg.setOnheapCacheEnabled(true);
                cacheCfg.setBackups(0);
                cacheCfg.setName(readThrough==1 ? "ReadThroughCache" : 
"EmptyCache");
                if (readThrough == 1) {
                        
cacheCfg.setCacheStoreFactory(FactoryBuilder.factoryOf(NullCache.class));
                        cacheCfg.setReadThrough(true);
                
cacheCfg.setExpiryPolicyFactory(AccessedExpiryPolicy.factoryOf(Duration.ZERO));
                }

                IgniteCache<Long, Long> longCache = 
ignite.getOrCreateCache(cacheCfg);
                Instant t1 = Instant.now();
                for (long i = 0; i < itemCount; i++) {
                        Long l = longCache.get(i);
                }
                Instant t2 = Instant.now();
                long readPerformance = (1000L * itemCount) /
java.time.Duration.between(t1, t2).toMillis();
                System.out.println(longCache.getName() + ": " + readPerformance 
+ "
reads/second");
        }
}

Result: 
        "C:\Program Files\Java\jdk1.8.0_45\bin\java"
        [21:17:35] ver. 2.0.0#20170430-sha1:d4eef3c6
        [21:17:35] OS: Windows 7 6.1 amd64
        [21:17:39] Topology snapshot [ver=1, servers=1, clients=0, CPUs=12,
heap=7.1GB]
*       EmptyCache: 928505 reads/second
        ReadThroughCache: 29709 reads/second*

I don't expect the same speed as an empty cache, but something seems wrong.
How can I improve this?
Thanks.
Pascal





--
View this message in context: 
http://apache-ignite-users.70518.x6.nabble.com/Read-through-cache-performance-tp14085.html
Sent from the Apache Ignite Users mailing list archive at Nabble.com.

Reply via email to