ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From yzhda...@apache.org
Subject [3/3] ignite git commit: Debugging slowdowns
Date Mon, 19 Oct 2015 13:27:09 GMT
Debugging slowdowns


Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/7aa851b5
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/7aa851b5
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/7aa851b5

Branch: refs/heads/ignite-1.4-slow-server-debug
Commit: 7aa851b5b64278c5d9dfe95306223d63bbcc3e12
Parents: f580ef9
Author: Yakov Zhdanov <yzhdanov@gridgain.com>
Authored: Mon Oct 19 16:27:06 2015 +0300
Committer: Yakov Zhdanov <yzhdanov@gridgain.com>
Committed: Mon Oct 19 16:27:06 2015 +0300

----------------------------------------------------------------------
 .../java/org/apache/ignite/internal/Bench.java  |   1 -
 .../cache/transactions/IgniteTxManager.java     | 186 +++++++++----------
 .../internal/util/GridConcurrentFactory.java    |  12 +-
 3 files changed, 94 insertions(+), 105 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/7aa851b5/modules/core/src/main/java/org/apache/ignite/internal/Bench.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/Bench.java b/modules/core/src/main/java/org/apache/ignite/internal/Bench.java
index 1d5f544..cc021bb 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/Bench.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/Bench.java
@@ -48,7 +48,6 @@ public class Bench {
 
         Thread.sleep(2000);
 
-
         final LongAdder8 cnt = new LongAdder8();
 
         final AtomicLong time = new AtomicLong(U.currentTimeMillis());

http://git-wip-us.apache.org/repos/asf/ignite/blob/7aa851b5/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxManager.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxManager.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxManager.java
index 032e043..a80980e 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxManager.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxManager.java
@@ -143,7 +143,8 @@ public class IgniteTxManager extends GridCacheSharedManagerAdapter {
 
     /** Committed local transactions. */
     private final GridBoundedConcurrentOrderedMap<GridCacheVersion, Boolean> completedVers
=
-        new GridBoundedConcurrentOrderedMap<>(Integer.getInteger(IGNITE_MAX_COMPLETED_TX_COUNT,
DFLT_MAX_COMPLETED_TX_CNT));
+        new GridBoundedConcurrentOrderedMap<>(
+            Integer.getInteger(IGNITE_MAX_COMPLETED_TX_COUNT, DFLT_MAX_COMPLETED_TX_CNT));
 
     /** Transaction finish synchronizer. */
     private GridCacheTxFinishSync txFinishSync;
@@ -851,10 +852,8 @@ public class IgniteTxManager extends GridCacheSharedManagerAdapter {
             GridCacheVersion finishTn = cctx.versions().last();
 
             // Add future to prepare queue only on first prepare call.
-//            if (tx.markPreparing())
-//                prepareQ.offer(tx);
-
-            tx.markPreparing();
+            if (tx.markPreparing())
+                prepareQ.offer(tx);
 
             // Check that our read set does not intersect with write set
             // of all transactions that completed their write phase
@@ -890,50 +889,50 @@ public class IgniteTxManager extends GridCacheSharedManagerAdapter {
 
             // Check that our read and write sets do not intersect with write
             // sets of all active transactions.
-//            for (Iterator<IgniteInternalTx> iter = prepareQ.iterator(); iter.hasNext();)
{
-//                IgniteInternalTx prepareTx = iter.next();
-//
-//                if (prepareTx == tx)
-//                    // Skip yourself.
-//                    continue;
-//
-//                // Optimistically remove completed transactions.
-//                if (prepareTx.done()) {
-//                    iter.remove();
-//
-//                    if (log.isDebugEnabled())
-//                        log.debug("Removed finished transaction from active queue: " +
prepareTx);
-//
-//                    continue;
-//                }
-//
-//                // Check if originating node left.
-//                if (cctx.discovery().node(prepareTx.nodeId()) == null) {
-//                    iter.remove();
-//
-//                    rollbackTx(prepareTx);
-//
-//                    if (log.isDebugEnabled())
-//                        log.debug("Removed and rolled back transaction because sender node
left grid: " +
-//                            CU.txString(prepareTx));
-//
-//                    continue;
-//                }
-//
-//                if (tx.serializable() && !prepareTx.isRollbackOnly()) {
-//                    Set<IgniteTxKey> prepareWriteSet = prepareTx.writeSet();
-//
-//                    if (GridFunc.intersects(prepareWriteSet, readSet, writeSet)) {
-//                        // Remove from active set.
-//                        iter.remove();
-//
-//                        tx.setRollbackOnly();
-//
-//                        throw new IgniteTxOptimisticCheckedException(
-//                            "Failed to prepare transaction (read-set/write-set conflict):
" + tx);
-//                    }
-//                }
-//            }
+            for (Iterator<IgniteInternalTx> iter = prepareQ.iterator(); iter.hasNext();)
{
+                IgniteInternalTx prepareTx = iter.next();
+
+                if (prepareTx == tx)
+                    // Skip yourself.
+                    continue;
+
+                // Optimistically remove completed transactions.
+                if (prepareTx.done()) {
+                    iter.remove();
+
+                    if (log.isDebugEnabled())
+                        log.debug("Removed finished transaction from active queue: " + prepareTx);
+
+                    continue;
+                }
+
+                // Check if originating node left.
+                if (cctx.discovery().node(prepareTx.nodeId()) == null) {
+                    iter.remove();
+
+                    rollbackTx(prepareTx);
+
+                    if (log.isDebugEnabled())
+                        log.debug("Removed and rolled back transaction because sender node
left grid: " +
+                            CU.txString(prepareTx));
+
+                    continue;
+                }
+
+                if (tx.serializable() && !prepareTx.isRollbackOnly()) {
+                    Set<IgniteTxKey> prepareWriteSet = prepareTx.writeSet();
+
+                    if (GridFunc.intersects(prepareWriteSet, readSet, writeSet)) {
+                        // Remove from active set.
+                        iter.remove();
+
+                        tx.setRollbackOnly();
+
+                        throw new IgniteTxOptimisticCheckedException(
+                            "Failed to prepare transaction (read-set/write-set conflict):
" + tx);
+                    }
+                }
+            }
         }
 
         // Optimistic.
@@ -1099,24 +1098,23 @@ public class IgniteTxManager extends GridCacheSharedManagerAdapter
{
      * @return If transaction was not already present in completed set.
      */
     public boolean addCommittedTx(GridCacheVersion xidVer, @Nullable GridCacheVersion nearXidVer)
{
-//        if (nearXidVer != null)
-//            xidVer = new CommittedVersion(xidVer, nearXidVer);
-//
-//        Boolean committed = completedVers.putIfAbsent(xidVer, true);
-//
-//        if (committed == null || committed) {
-//            if (log.isDebugEnabled())
-//                log.debug("Added transaction to committed version set: " + xidVer);
-//
-//            return true;
-//        }
-//        else {
-//            if (log.isDebugEnabled())
-//                log.debug("Transaction is already present in rolled back version set: "
+ xidVer);
-//
-//            return false;
-//        }
-        return true;
+        if (nearXidVer != null)
+            xidVer = new CommittedVersion(xidVer, nearXidVer);
+
+        Boolean committed = completedVers.putIfAbsent(xidVer, true);
+
+        if (committed == null || committed) {
+            if (log.isDebugEnabled())
+                log.debug("Added transaction to committed version set: " + xidVer);
+
+            return true;
+        }
+        else {
+            if (log.isDebugEnabled())
+                log.debug("Transaction is already present in rolled back version set: " +
xidVer);
+
+            return false;
+        }
     }
 
     /**
@@ -1124,22 +1122,20 @@ public class IgniteTxManager extends GridCacheSharedManagerAdapter
{
      * @return If transaction was not already present in completed set.
      */
     public boolean addRolledbackTx(GridCacheVersion xidVer) {
+        Boolean committed = completedVers.putIfAbsent(xidVer, false);
 
-        return true;
-//        Boolean committed = completedVers.putIfAbsent(xidVer, false);
-//
-//        if (committed == null || !committed) {
-//            if (log.isDebugEnabled())
-//                log.debug("Added transaction to rolled back version set: " + xidVer);
-//
-//            return true;
-//        }
-//        else {
-//            if (log.isDebugEnabled())
-//                log.debug("Transaction is already present in committed version set: " +
xidVer);
-//
-//            return false;
-//        }
+        if (committed == null || !committed) {
+            if (log.isDebugEnabled())
+                log.debug("Added transaction to rolled back version set: " + xidVer);
+
+            return true;
+        }
+        else {
+            if (log.isDebugEnabled())
+                log.debug("Transaction is already present in committed version set: " + xidVer);
+
+            return false;
+        }
     }
 
     /**
@@ -1266,19 +1262,19 @@ public class IgniteTxManager extends GridCacheSharedManagerAdapter
{
          * so we don't do it here.
          */
 
-//        Boolean committed = completedVers.get(tx.xidVersion());
-//
-//        // 1. Make sure that committed version has been recorded.
-//        if (!((committed != null && committed) || tx.writeSet().isEmpty() || tx.isSystemInvalidate()))
{
-//            uncommitTx(tx);
-//
-//            GridCacheVersion first = completedVers.isEmpty() ? null : completedVers.firstKey();
-//            GridCacheVersion last = completedVers.isEmpty() ? null : completedVers.lastKey();
-//
-//            throw new IgniteException("Missing commit version (consider increasing " +
-//                IGNITE_MAX_COMPLETED_TX_COUNT + " system property) [ver=" + tx.xidVersion()
+ ", firstVer=" +
-//                first + ", lastVer=" + last + ", tx=" + tx.xid() + ']');
-//        }
+        Boolean committed = completedVers.get(tx.xidVersion());
+
+        // 1. Make sure that committed version has been recorded.
+        if (!((committed != null && committed) || tx.writeSet().isEmpty() || tx.isSystemInvalidate()))
{
+            uncommitTx(tx);
+
+            GridCacheVersion first = completedVers.isEmpty() ? null : completedVers.firstKey();
+            GridCacheVersion last = completedVers.isEmpty() ? null : completedVers.lastKey();
+
+            throw new IgniteException("Missing commit version (consider increasing " +
+                IGNITE_MAX_COMPLETED_TX_COUNT + " system property) [ver=" + tx.xidVersion()
+ ", firstVer=" +
+                first + ", lastVer=" + last + ", tx=" + tx.xid() + ']');
+        }
 
         ConcurrentMap<GridCacheVersion, IgniteInternalTx> txIdMap = transactionMap(tx);
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/7aa851b5/modules/core/src/main/java/org/apache/ignite/internal/util/GridConcurrentFactory.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/GridConcurrentFactory.java
b/modules/core/src/main/java/org/apache/ignite/internal/util/GridConcurrentFactory.java
index 6e0e876..bb933fe 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/util/GridConcurrentFactory.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/util/GridConcurrentFactory.java
@@ -17,19 +17,14 @@
 
 package org.apache.ignite.internal.util;
 
-import java.util.concurrent.ConcurrentMap;
-import org.apache.ignite.IgniteSystemProperties;
 import org.jsr166.ConcurrentHashMap8;
 
-import static org.apache.ignite.IgniteSystemProperties.IGNITE_MAP_CONCURRENCY_LEVEL;
+import java.util.concurrent.ConcurrentMap;
 
 /**
  * Concurrent map factory.
  */
 public class GridConcurrentFactory {
-    /** Default concurrency level. */
-    private static final int CONCURRENCY_LEVEL = IgniteSystemProperties.getInteger(IGNITE_MAP_CONCURRENCY_LEVEL,
256);
-
     /**
      * Ensure singleton.
      */
@@ -43,7 +38,6 @@ public class GridConcurrentFactory {
      * @return New concurrent map.
      */
     public static <K, V> ConcurrentMap<K, V> newMap() {
-        return new ConcurrentHashMap8<>(16 * CONCURRENCY_LEVEL, 0.75f, CONCURRENCY_LEVEL);
+        return new ConcurrentHashMap8<>();
     }
-
-}
\ No newline at end of file
+}


Mime
View raw message