You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ignite.apache.org by NO <72...@qq.com> on 2018/08/09 08:53:59 UTC

When using CacheMode.LOCAL, OOM

Hi,
    I'm going to use Ignite instead of guava. During testing, I find that CacheMode.LOCAL is often OOM. Please help me check what's wrong with it. Thank you very much.



    Ignite version : 2.6.0


    jdk 1.8.0_151-b12


    Test Code :
==============
public class LocalCacheDemo {
    public static void main(String[] args) throws InterruptedException {

        String cacheName = "localCache";
        String regionName = "localRegin";

        DataStorageConfiguration dataStorageConfiguration = new DataStorageConfiguration();

        DataRegionConfiguration localReginConf = new DataRegionConfiguration();
        localReginConf.setName(regionName);
        localReginConf.setMetricsEnabled(true);
        localReginConf.setPersistenceEnabled(false);
        localReginConf.setInitialSize(256 * 1024 * 1024);
        long max = 2L * 1024L * 1024L * 1024L;
        localReginConf.setMaxSize(max);
        localReginConf.setPageEvictionMode(DataPageEvictionMode.RANDOM_2_LRU);
        dataStorageConfiguration.setDataRegionConfigurations(localReginConf);
        dataStorageConfiguration.setPageSize(1024 * 8);

        CacheConfiguration cacheCfg = new CacheConfiguration(cacheName);
        cacheCfg.setCacheMode(CacheMode.LOCAL);
        cacheCfg.setDataRegionName(regionName);
        cacheCfg.setBackups(0);
        cacheCfg.setStatisticsEnabled(true);
        cacheCfg.setAtomicityMode(CacheAtomicityMode.ATOMIC);
        cacheCfg.setOnheapCacheEnabled(false);

        IgniteConfiguration cfg = new IgniteConfiguration();
        cfg.setCacheConfiguration(cacheCfg);
        cfg.setDataStorageConfiguration(dataStorageConfiguration);

        Ignite ignite = Ignition.start(cfg);

        final ClusterGroup clusterGroup = ignite.cluster().forLocal();

        final IgniteCache<String, byte[]> cache = ignite.getOrCreateCache(cacheName);

        final ExecutorService pool = Executors.newFixedThreadPool(8);

        for (int i = 0; i < 8; i++) {
            pool.submit(new Runnable() {
                @Override
                public void run() {
                    while (true) {
                        cache.put(UUID.randomUUID().toString(), UUID.randomUUID().toString().getBytes());
                    }
                }
            });
        }
    }
}

==============
JVM param:


 -server -XX:+UseG1GC -XX:+AlwaysPreTouch -XX:+ScavengeBeforeFullGC -Xmx2g -Xms2g -XX:MaxMetaspaceSize=100m -XX:MaxGCPauseMillis=100 -XX:+PrintGCDetails -XX:+PrintTenuringDistribution -XX:+PrintGCDateStamps -XX:+PrintGCApplicationStoppedTime -XX:NumberOfGCLogFiles=1 -XX:GCLogFileSize=256M -Xloggc:/home/qipu/production/localCache/gc.log 

===============
===============
GC log:


2018-08-09T16:36:59.630+0800: 750.387: Total time for which application threads were stopped: 0.0104034 seconds
2018-08-09T16:36:59.630+0800: 750.387: [GC pause (G1 Evacuation Pause) (young) (initial-mark)
Desired survivor size 6815744 bytes, new threshold 15 (max 15)
, 0.0041734 secs]
   [Parallel Time: 3.1 ms, GC Workers: 4]
      [GC Worker Start (ms): Min: 750387.6, Avg: 750387.7, Max: 750387.8, Diff: 0.1]
      [Ext Root Scanning (ms): Min: 0.3, Avg: 0.5, Max: 0.9, Diff: 0.6, Sum: 2.1]
      [Code Root Marking (ms): Min: 0.2, Avg: 0.6, Max: 1.5, Diff: 1.3, Sum: 2.6]
      [Update RS (ms): Min: 0.6, Avg: 1.4, Max: 1.8, Diff: 1.2, Sum: 5.6]
         [Processed Buffers: Min: 2, Avg: 3.5, Max: 5, Diff: 3, Sum: 14]
      [Scan RS (ms): Min: 0.0, Avg: 0.0, Max: 0.0, Diff: 0.0, Sum: 0.0]
      [Code Root Scanning (ms): Min: 0.0, Avg: 0.0, Max: 0.0, Diff: 0.0, Sum: 0.0]
      [Object Copy (ms): Min: 0.1, Avg: 0.3, Max: 0.4, Diff: 0.3, Sum: 1.3]
      [Termination (ms): Min: 0.0, Avg: 0.1, Max: 0.2, Diff: 0.2, Sum: 0.4]
      [GC Worker Other (ms): Min: 0.0, Avg: 0.0, Max: 0.0, Diff: 0.0, Sum: 0.0]
      [GC Worker Total (ms): Min: 2.9, Avg: 3.0, Max: 3.0, Diff: 0.1, Sum: 11.9]
      [GC Worker End (ms): Min: 750390.7, Avg: 750390.7, Max: 750390.7, Diff: 0.0]
   [Code Root Fixup: 0.1 ms]
   [Code Root Migration: 0.0 ms]
   [Clear CT: 0.1 ms]
   [Other: 0.9 ms]
      [Choose CSet: 0.0 ms]
      [Ref Proc: 0.2 ms]
      [Ref Enq: 0.0 ms]
      [Free CSet: 0.0 ms]
   [Eden: 0.0B(102.0M)->0.0B(102.0M) Survivors: 0.0B->0.0B Heap: 2046.5M(2048.0M)->2046.5M(2048.0M)]
 [Times: user=0.01 sys=0.00, real=0.00 secs] 
2018-08-09T16:36:59.635+0800: 750.392: Total time for which application threads were stopped: 0.0045325 seconds
2018-08-09T16:36:59.635+0800: 750.392: [GC concurrent-root-region-scan-start]
2018-08-09T16:36:59.635+0800: 750.392: [GC concurrent-root-region-scan-end, 0.0000078 secs]
2018-08-09T16:36:59.635+0800: 750.392: [GC concurrent-mark-start]
2018-08-09T16:36:59.635+0800: 750.392: [Full GC (Allocation Failure) 

===============

Re: When using CacheMode.LOCAL, OOM

Posted by dkarachentsev <dk...@gridgain.com>.
Hi, 

I've opened a ticket for this [1]. It seems LOCAL cache keeps all entries
on-heap. If you use only one node - switch to PARTITIONED, if more than one
- PARTITIONED + node filter [2]

[1] https://issues.apache.org/jira/browse/IGNITE-9257
[2]
https://ignite.apache.org/releases/latest/javadoc/org/apache/ignite/configuration/CacheConfiguration.html#setNodeFilter-org.apache.ignite.lang.IgnitePredicate-

Thanks!
-Dmitry



--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/