Optimistic transaction very slow on v1.3.2 community edition

classic Classic list List threaded Threaded
4 messages Options
Sajal Gupta Sajal Gupta
Reply | Threaded
Open this post in threaded view
|

Optimistic transaction very slow on v1.3.2 community edition

Trying the below sample where I am putting 20000 entries in cache within transaction on a single node(JRE 7, heap 4GB),it takes more than 20sec to commit. The thread dumps below shows thread executing GridCacheMvccManager.addNext most of the time.The same sample with pessimistic mode takes less than 5sec
Let me know if there is any other setting that should be specified or is it the best we can get considering everything is happening in memory on single node?

       URL url = TestCache.class.getResource("/unittest/gridgain/example-ignite.xml");
         Ignite ignite = Ignition.start(url);
         System.out.println();
         System.out.println(">>> Cache API example started.");

         CacheConfiguration cfg = new CacheConfiguration();
         cfg.setName("myCache");
         cfg.setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL);
         cfg.setCacheMode(CacheMode.PARTITIONED);
         cfg.setMemoryMode(CacheMemoryMode.OFFHEAP_TIERED);
         cfg.setRebalanceMode(CacheRebalanceMode.ASYNC);
         cfg.setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_ASYNC);
         cfg.setOffHeapMaxMemory(2 * 1024L * 1024L * 1024L);
         IgniteCache<String,byte[]> cache = ignite.createCache(cfg);

         byte[] valArr = new byte[16000];
         for(int i=0;i<valArr.length;i++){
          valArr[i] = 0x0;
         }
         long t1 = System.currentTimeMillis();
         try (Transaction tx = (Transaction)Ignition.ignite().transactions().txStart(TransactionConcurrency.OPTIMISTIC,TransactionIsolation.REPEATABLE_READ)){
          for(int i=0;i<20000;i++){
           cache.put("K"+(long)i,valArr);           
          }
          tx.commit();
         }
         long t2 = System.currentTimeMillis();
         System.out.println("Time taken:"  + (t2-t1));


"main" prio=6 tid=0x0000000002c33800 nid=0x454 runnable [0x0000000002b4e000]
   java.lang.Thread.State: RUNNABLE
 at java.util.LinkedList.add(LinkedList.java:336)
 at org.apache.ignite.internal.processors.cache.GridCacheMvccManager.addNext(GridCacheMvccManager.java:733)
 at org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtCacheEntry.addDhtLocal(GridDhtCacheEntry.java:230)
 at org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtCacheEntry.tmLock(GridDhtCacheEntry.java:244)
 at org.apache.ignite.internal.processors.cache.transactions.IgniteTxManager.lockMultiple(IgniteTxManager.java:1586)
 at org.apache.ignite.internal.processors.cache.transactions.IgniteTxManager.prepareTx(IgniteTxManager.java:882)
 at org.apache.ignite.internal.processors.cache.transactions.IgniteTxLocalAdapter.userPrepare(IgniteTxLocalAdapter.java:410)
 at org.apache.ignite.internal.processors.cache.distributed.near.GridNearTxLocal.prepareAsyncLocal(GridNearTxLocal.java:852)
yakov yakov
Reply | Threaded
Open this post in threaded view
|

Re: Optimistic transaction very slow on v1.3.2 community edition

Sajal, thanks for pointing out and investigation. This is a known issue that on very large batches there are slowdowns in MVCC. I believe this has been fixed by Alex Goncharuk and will be released soon. Alex is this the case?

--Yakov

2015-07-29 14:07 GMT+03:00 Sajal Gupta <[hidden email]>:

Trying the below sample where I am putting 20000 entries in cache within transaction on a single node(JRE 7, heap 4GB),it takes more than 20sec to commit. The thread dumps below shows thread executing GridCacheMvccManager.addNext most of the time.The same sample with pessimistic mode takes less than 5sec
Let me know if there is any other setting that should be specified or is it the best we can get considering everything is happening in memory on single node?

       URL url = TestCache.class.getResource("/unittest/gridgain/example-ignite.xml");
         Ignite ignite = Ignition.start(url);
         System.out.println();
         System.out.println(">>> Cache API example started.");

         CacheConfiguration cfg = new CacheConfiguration();
         cfg.setName("myCache");
         cfg.setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL);
         cfg.setCacheMode(CacheMode.PARTITIONED);
         cfg.setMemoryMode(CacheMemoryMode.OFFHEAP_TIERED);
         cfg.setRebalanceMode(CacheRebalanceMode.ASYNC);
         cfg.setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_ASYNC);
         cfg.setOffHeapMaxMemory(2 * 1024L * 1024L * 1024L);
         IgniteCache<String,byte[]> cache = ignite.createCache(cfg);

         byte[] valArr = new byte[16000];
         for(int i=0;i<valArr.length;i++){
          valArr[i] = 0x0;
         }
         long t1 = System.currentTimeMillis();
         try (Transaction tx = (Transaction)Ignition.ignite().transactions().txStart(TransactionConcurrency.OPTIMISTIC,TransactionIsolation.REPEATABLE_READ)){
          for(int i=0;i<20000;i++){
           cache.put("K"+(long)i,valArr);           
          }
          tx.commit();
         }
         long t2 = System.currentTimeMillis();
         System.out.println("Time taken:"  + (t2-t1));


"main" prio=6 tid=0x0000000002c33800 nid=0x454 runnable [0x0000000002b4e000]
   java.lang.Thread.State: RUNNABLE
 at java.util.LinkedList.add(LinkedList.java:336)
 at org.apache.ignite.internal.processors.cache.GridCacheMvccManager.addNext(GridCacheMvccManager.java:733)
 at org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtCacheEntry.addDhtLocal(GridDhtCacheEntry.java:230)
 at org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtCacheEntry.tmLock(GridDhtCacheEntry.java:244)
 at org.apache.ignite.internal.processors.cache.transactions.IgniteTxManager.lockMultiple(IgniteTxManager.java:1586)
 at org.apache.ignite.internal.processors.cache.transactions.IgniteTxManager.prepareTx(IgniteTxManager.java:882)
 at org.apache.ignite.internal.processors.cache.transactions.IgniteTxLocalAdapter.userPrepare(IgniteTxLocalAdapter.java:410)
 at org.apache.ignite.internal.processors.cache.distributed.near.GridNearTxLocal.prepareAsyncLocal(GridNearTxLocal.java:852)

alexey.goncharuk alexey.goncharuk
Reply | Threaded
Open this post in threaded view
|

Re: Optimistic transaction very slow on v1.3.2 community edition

Sajal, thanks for your input! I have almost finished working on the fix, it should get to one of the next releases of Ignite. You can track this ticket https://issues.apache.org/jira/browse/IGNITE-1159 to see when it's merged to master.

2015-07-29 6:34 GMT-07:00 Yakov Zhdanov <[hidden email]>:
Sajal, thanks for pointing out and investigation. This is a known issue that on very large batches there are slowdowns in MVCC. I believe this has been fixed by Alex Goncharuk and will be released soon. Alex is this the case?

--Yakov

2015-07-29 14:07 GMT+03:00 Sajal Gupta <[hidden email]>:

Trying the below sample where I am putting 20000 entries in cache within transaction on a single node(JRE 7, heap 4GB),it takes more than 20sec to commit. The thread dumps below shows thread executing GridCacheMvccManager.addNext most of the time.The same sample with pessimistic mode takes less than 5sec
Let me know if there is any other setting that should be specified or is it the best we can get considering everything is happening in memory on single node?

       URL url = TestCache.class.getResource("/unittest/gridgain/example-ignite.xml");
         Ignite ignite = Ignition.start(url);
         System.out.println();
         System.out.println(">>> Cache API example started.");

         CacheConfiguration cfg = new CacheConfiguration();
         cfg.setName("myCache");
         cfg.setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL);
         cfg.setCacheMode(CacheMode.PARTITIONED);
         cfg.setMemoryMode(CacheMemoryMode.OFFHEAP_TIERED);
         cfg.setRebalanceMode(CacheRebalanceMode.ASYNC);
         cfg.setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_ASYNC);
         cfg.setOffHeapMaxMemory(2 * 1024L * 1024L * 1024L);
         IgniteCache<String,byte[]> cache = ignite.createCache(cfg);

         byte[] valArr = new byte[16000];
         for(int i=0;i<valArr.length;i++){
          valArr[i] = 0x0;
         }
         long t1 = System.currentTimeMillis();
         try (Transaction tx = (Transaction)Ignition.ignite().transactions().txStart(TransactionConcurrency.OPTIMISTIC,TransactionIsolation.REPEATABLE_READ)){
          for(int i=0;i<20000;i++){
           cache.put("K"+(long)i,valArr);           
          }
          tx.commit();
         }
         long t2 = System.currentTimeMillis();
         System.out.println("Time taken:"  + (t2-t1));


"main" prio=6 tid=0x0000000002c33800 nid=0x454 runnable [0x0000000002b4e000]
   java.lang.Thread.State: RUNNABLE
 at java.util.LinkedList.add(LinkedList.java:336)
 at org.apache.ignite.internal.processors.cache.GridCacheMvccManager.addNext(GridCacheMvccManager.java:733)
 at org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtCacheEntry.addDhtLocal(GridDhtCacheEntry.java:230)
 at org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtCacheEntry.tmLock(GridDhtCacheEntry.java:244)
 at org.apache.ignite.internal.processors.cache.transactions.IgniteTxManager.lockMultiple(IgniteTxManager.java:1586)
 at org.apache.ignite.internal.processors.cache.transactions.IgniteTxManager.prepareTx(IgniteTxManager.java:882)
 at org.apache.ignite.internal.processors.cache.transactions.IgniteTxLocalAdapter.userPrepare(IgniteTxLocalAdapter.java:410)
 at org.apache.ignite.internal.processors.cache.distributed.near.GridNearTxLocal.prepareAsyncLocal(GridNearTxLocal.java:852)


Sajal Gupta Sajal Gupta
Reply | Threaded
Open this post in threaded view
|

Re: Optimistic transaction very slow on v1.3.2 community edition

Sure, Thank you.

Sajal.

On Wed, Jul 29, 2015 at 11:11 PM, Alexey Goncharuk <[hidden email]> wrote:
Sajal, thanks for your input! I have almost finished working on the fix, it should get to one of the next releases of Ignite. You can track this ticket https://issues.apache.org/jira/browse/IGNITE-1159 to see when it's merged to master.

2015-07-29 6:34 GMT-07:00 Yakov Zhdanov <[hidden email]>:
Sajal, thanks for pointing out and investigation. This is a known issue that on very large batches there are slowdowns in MVCC. I believe this has been fixed by Alex Goncharuk and will be released soon. Alex is this the case?

--Yakov

2015-07-29 14:07 GMT+03:00 Sajal Gupta <[hidden email]>:

Trying the below sample where I am putting 20000 entries in cache within transaction on a single node(JRE 7, heap 4GB),it takes more than 20sec to commit. The thread dumps below shows thread executing GridCacheMvccManager.addNext most of the time.The same sample with pessimistic mode takes less than 5sec
Let me know if there is any other setting that should be specified or is it the best we can get considering everything is happening in memory on single node?

       URL url = TestCache.class.getResource("/unittest/gridgain/example-ignite.xml");
         Ignite ignite = Ignition.start(url);
         System.out.println();
         System.out.println(">>> Cache API example started.");

         CacheConfiguration cfg = new CacheConfiguration();
         cfg.setName("myCache");
         cfg.setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL);
         cfg.setCacheMode(CacheMode.PARTITIONED);
         cfg.setMemoryMode(CacheMemoryMode.OFFHEAP_TIERED);
         cfg.setRebalanceMode(CacheRebalanceMode.ASYNC);
         cfg.setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_ASYNC);
         cfg.setOffHeapMaxMemory(2 * 1024L * 1024L * 1024L);
         IgniteCache<String,byte[]> cache = ignite.createCache(cfg);

         byte[] valArr = new byte[16000];
         for(int i=0;i<valArr.length;i++){
          valArr[i] = 0x0;
         }
         long t1 = System.currentTimeMillis();
         try (Transaction tx = (Transaction)Ignition.ignite().transactions().txStart(TransactionConcurrency.OPTIMISTIC,TransactionIsolation.REPEATABLE_READ)){
          for(int i=0;i<20000;i++){
           cache.put("K"+(long)i,valArr);           
          }
          tx.commit();
         }
         long t2 = System.currentTimeMillis();
         System.out.println("Time taken:"  + (t2-t1));


"main" prio=6 tid=0x0000000002c33800 nid=0x454 runnable [0x0000000002b4e000]
   java.lang.Thread.State: RUNNABLE
 at java.util.LinkedList.add(LinkedList.java:336)
 at org.apache.ignite.internal.processors.cache.GridCacheMvccManager.addNext(GridCacheMvccManager.java:733)
 at org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtCacheEntry.addDhtLocal(GridDhtCacheEntry.java:230)
 at org.apache.ignite.internal.processors.cache.distributed.dht.GridDhtCacheEntry.tmLock(GridDhtCacheEntry.java:244)
 at org.apache.ignite.internal.processors.cache.transactions.IgniteTxManager.lockMultiple(IgniteTxManager.java:1586)
 at org.apache.ignite.internal.processors.cache.transactions.IgniteTxManager.prepareTx(IgniteTxManager.java:882)
 at org.apache.ignite.internal.processors.cache.transactions.IgniteTxLocalAdapter.userPrepare(IgniteTxLocalAdapter.java:410)
 at org.apache.ignite.internal.processors.cache.distributed.near.GridNearTxLocal.prepareAsyncLocal(GridNearTxLocal.java:852)