You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by yz...@apache.org on 2015/11/24 16:23:15 UTC

ignite git commit: debugging slowdowns

Repository: ignite
Updated Branches:
  refs/heads/ignite-1.5-cache-get-opts [created] 3289cc1ff


debugging slowdowns


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

Branch: refs/heads/ignite-1.5-cache-get-opts
Commit: 3289cc1ff3a31f6c693007df6fa8920f05afeb6b
Parents: c23cda1
Author: Yakov Zhdanov <yz...@gridgain.com>
Authored: Tue Nov 24 18:22:48 2015 +0300
Committer: Yakov Zhdanov <yz...@gridgain.com>
Committed: Tue Nov 24 18:22:48 2015 +0300

----------------------------------------------------------------------
 .../apache/ignite/cache/CacheInterceptor.java   |  2 +-
 .../rendezvous/RendezvousAffinityFunction.java  |  2 +-
 .../processors/cache/GridCacheAdapter.java      | 65 +++++++++++++++-----
 .../cache/GridCacheConcurrentMap.java           | 16 +----
 .../processors/cache/GridCacheMapEntry.java     |  4 +-
 .../distributed/dht/GridDhtCacheAdapter.java    |  4 +-
 .../cache/distributed/dht/GridDhtGetFuture.java | 28 ++++++---
 .../dht/GridPartitionedSingleGetFuture.java     |  9 ++-
 .../util/future/GridCompoundFuture.java         |  5 +-
 .../internal/util/future/GridFutureAdapter.java |  2 +-
 10 files changed, 87 insertions(+), 50 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/3289cc1f/modules/core/src/main/java/org/apache/ignite/cache/CacheInterceptor.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/cache/CacheInterceptor.java b/modules/core/src/main/java/org/apache/ignite/cache/CacheInterceptor.java
index 436db6b..103fe57 100644
--- a/modules/core/src/main/java/org/apache/ignite/cache/CacheInterceptor.java
+++ b/modules/core/src/main/java/org/apache/ignite/cache/CacheInterceptor.java
@@ -120,4 +120,4 @@ public interface CacheInterceptor<K, V> extends Serializable {
      *      entry is a copy.
      */
     public void onAfterRemove(Cache.Entry<K, V> entry);
-}
\ No newline at end of file
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/3289cc1f/modules/core/src/main/java/org/apache/ignite/cache/affinity/rendezvous/RendezvousAffinityFunction.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/cache/affinity/rendezvous/RendezvousAffinityFunction.java b/modules/core/src/main/java/org/apache/ignite/cache/affinity/rendezvous/RendezvousAffinityFunction.java
index 61a21d3..37258d4 100644
--- a/modules/core/src/main/java/org/apache/ignite/cache/affinity/rendezvous/RendezvousAffinityFunction.java
+++ b/modules/core/src/main/java/org/apache/ignite/cache/affinity/rendezvous/RendezvousAffinityFunction.java
@@ -480,4 +480,4 @@ public class RendezvousAffinityFunction implements AffinityFunction, Externaliza
                 o1.get2().id().compareTo(o2.get2().id());
         }
     }
-}
\ No newline at end of file
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/3289cc1f/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java
index 26a3acd..ca59629 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java
@@ -924,25 +924,60 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V
      */
     @Nullable private GridCacheEntryEx entry0(KeyCacheObject key, AffinityTopologyVersion topVer, boolean create,
         boolean touch) {
-        GridTriple<GridCacheMapEntry> t = map.putEntryIfObsoleteOrAbsent(topVer, key, null, create);
+        GridCacheMapEntry cur = map.getEntry(key);
 
-        GridCacheEntryEx cur = t.get1();
-        GridCacheEntryEx created = t.get2();
-        GridCacheEntryEx doomed = t.get3();
+        if (cur == null || cur.obsolete()) {
+            GridTriple<GridCacheMapEntry> t = map.putEntryIfObsoleteOrAbsent(
+                topVer,
+                key,
+                null,
+                create);
 
-        if (doomed != null && ctx.events().isRecordable(EVT_CACHE_ENTRY_DESTROYED))
-            // Event notification.
-            ctx.events().addEvent(doomed.partition(), doomed.key(), locNodeId, (IgniteUuid)null, null,
-                EVT_CACHE_ENTRY_DESTROYED, null, false, null, false, null, null, null, true);
+            cur = t.get1();
 
-        if (created != null) {
-            // Event notification.
-            if (ctx.events().isRecordable(EVT_CACHE_ENTRY_CREATED))
-                ctx.events().addEvent(created.partition(), created.key(), locNodeId, (IgniteUuid)null, null,
-                    EVT_CACHE_ENTRY_CREATED, null, false, null, false, null, null, null, true);
+            GridCacheEntryEx created = t.get2();
+            GridCacheEntryEx doomed = t.get3();
 
-            if (touch)
-                ctx.evicts().touch(cur, topVer);
+            if (doomed != null && ctx.events().isRecordable(EVT_CACHE_ENTRY_DESTROYED))
+                // Event notification.
+                ctx.events().addEvent(doomed.partition(),
+                    doomed.key(),
+                    locNodeId,
+                    (IgniteUuid)null,
+                    null,
+                    EVT_CACHE_ENTRY_DESTROYED,
+                    null,
+                    false,
+                    null,
+                    false,
+                    null,
+                    null,
+                    null,
+                    true);
+
+            if (created != null) {
+                // Event notification.
+                if (ctx.events().isRecordable(EVT_CACHE_ENTRY_CREATED))
+                    ctx.events().addEvent(created.partition(),
+                        created.key(),
+                        locNodeId,
+                        (IgniteUuid)null,
+                        null,
+                        EVT_CACHE_ENTRY_CREATED,
+                        null,
+                        false,
+                        null,
+                        false,
+                        null,
+                        null,
+                        null,
+                        true);
+
+                if (touch)
+                    ctx.evicts().touch(
+                        cur,
+                        topVer);
+            }
         }
 
         return cur;

http://git-wip-us.apache.org/repos/asf/ignite/blob/3289cc1f/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheConcurrentMap.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheConcurrentMap.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheConcurrentMap.java
index fac704b..8293044 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheConcurrentMap.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheConcurrentMap.java
@@ -72,7 +72,7 @@ public class GridCacheConcurrentMap {
     private static final float DFLT_LOAD_FACTOR = 0.75f;
 
     /** The default concurrency level for this map. */
-    private static final int DFLT_CONCUR_LEVEL = 2048;
+    private static final int DFLT_CONCUR_LEVEL = Runtime.getRuntime().availableProcessors() * 2;
 
     /**
      * The maximum capacity, used if a higher value is implicitly specified by either
@@ -315,20 +315,6 @@ public class GridCacheConcurrentMap {
     }
 
     /**
-     * Creates a new, empty map with the specified initial capacity,
-     * and with default load factor (0.75) and concurrencyLevel (16).
-     *
-     * @param ctx Cache context.
-     * @param initCap the initial capacity. The implementation
-     *      performs internal sizing to accommodate this many elements.
-     * @throws IllegalArgumentException if the initial capacity of
-     *      elements is negative.
-     */
-    public GridCacheConcurrentMap(GridCacheContext ctx, int initCap) {
-        this(ctx, initCap, DFLT_LOAD_FACTOR, DFLT_CONCUR_LEVEL);
-    }
-
-    /**
      * Sets factory for entries.
      *
      * @param factory Entry factory.

http://git-wip-us.apache.org/repos/asf/ignite/blob/3289cc1f/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMapEntry.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMapEntry.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMapEntry.java
index ac42121..e1f2ade 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMapEntry.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheMapEntry.java
@@ -3012,7 +3012,7 @@ public abstract class GridCacheMapEntry extends GridMetadataAwareAdapter impleme
      * @return Next entry.
      */
     GridCacheMapEntry next(int segId) {
-        return segId % 2 == 0 ? next0 : next1;
+        return (segId & 1) == 0 ? next0 : next1;
     }
 
     /**
@@ -3022,7 +3022,7 @@ public abstract class GridCacheMapEntry extends GridMetadataAwareAdapter impleme
      * @param next Next entry.
      */
     void next(int segId, @Nullable GridCacheMapEntry next) {
-        if (segId % 2 == 0)
+        if ((segId & 1) == 0)
             next0 = next;
         else
             next1 = next;

http://git-wip-us.apache.org/repos/asf/ignite/blob/3289cc1f/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtCacheAdapter.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtCacheAdapter.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtCacheAdapter.java
index 8537357..0b759db 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtCacheAdapter.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtCacheAdapter.java
@@ -607,7 +607,7 @@ public abstract class GridDhtCacheAdapter<K, V> extends GridDistributedCacheAdap
 
     /**
      * This method is used internally. Use
-     * {@link #getDhtAsync(UUID, long, LinkedHashMap, boolean, AffinityTopologyVersion, UUID, int, IgniteCacheExpiryPolicy, boolean)}
+     * {@link #getDhtAsync(UUID, long, Map, boolean, AffinityTopologyVersion, UUID, int, IgniteCacheExpiryPolicy, boolean)}
      * method instead to retrieve DHT value.
      *
      * @param keys {@inheritDoc}
@@ -685,7 +685,7 @@ public abstract class GridDhtCacheAdapter<K, V> extends GridDistributedCacheAdap
      */
     public GridDhtFuture<Collection<GridCacheEntryInfo>> getDhtAsync(UUID reader,
         long msgId,
-        LinkedHashMap<KeyCacheObject, Boolean> keys,
+        Map<KeyCacheObject, Boolean> keys,
         boolean readThrough,
         AffinityTopologyVersion topVer,
         @Nullable UUID subjId,

http://git-wip-us.apache.org/repos/asf/ignite/blob/3289cc1f/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtGetFuture.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtGetFuture.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtGetFuture.java
index 6b696b0..626713a 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtGetFuture.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridDhtGetFuture.java
@@ -21,7 +21,6 @@ import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Collections;
 import java.util.HashSet;
-import java.util.LinkedHashMap;
 import java.util.Map;
 import java.util.UUID;
 import java.util.concurrent.atomic.AtomicReference;
@@ -80,7 +79,7 @@ public final class GridDhtGetFuture<K, V> extends GridCompoundIdentityFuture<Col
     private GridCacheContext<K, V> cctx;
 
     /** Keys. */
-    private LinkedHashMap<KeyCacheObject, Boolean> keys;
+    private Map<KeyCacheObject, Boolean> keys;
 
     /** Reserved partitions. */
     private Collection<GridDhtLocalPartition> parts = new HashSet<>();
@@ -129,7 +128,7 @@ public final class GridDhtGetFuture<K, V> extends GridCompoundIdentityFuture<Col
         GridCacheContext<K, V> cctx,
         long msgId,
         UUID reader,
-        LinkedHashMap<KeyCacheObject, Boolean> keys,
+        Map<KeyCacheObject, Boolean> keys,
         boolean readThrough,
         @Nullable IgniteTxLocalEx tx,
         @NotNull AffinityTopologyVersion topVer,
@@ -207,7 +206,7 @@ public final class GridDhtGetFuture<K, V> extends GridCompoundIdentityFuture<Col
     /**
      * @param keys Keys.
      */
-    private void map(final LinkedHashMap<KeyCacheObject, Boolean> keys) {
+    private void map(final Map<KeyCacheObject, Boolean> keys) {
         GridDhtFuture<Object> fut = cctx.dht().dhtPreloader().request(keys.keySet(), topVer);
 
         if (!F.isEmpty(fut.invalidPartitions())) {
@@ -227,7 +226,7 @@ public final class GridDhtGetFuture<K, V> extends GridCompoundIdentityFuture<Col
                         onDone(e);
                     }
 
-                    LinkedHashMap<KeyCacheObject, Boolean> mappedKeys = U.newLinkedHashMap(keys.size());
+                    Map<KeyCacheObject, Boolean> mappedKeys = null;
 
                     // Assign keys to primary nodes.
                     for (Map.Entry<KeyCacheObject, Boolean> key : keys.entrySet()) {
@@ -239,14 +238,25 @@ public final class GridDhtGetFuture<K, V> extends GridCompoundIdentityFuture<Col
                                     retries = new HashSet<>();
 
                                 retries.add(part);
+
+                                if (mappedKeys == null) {
+                                    mappedKeys = U.newLinkedHashMap(keys.size());
+
+                                    for (Map.Entry<KeyCacheObject, Boolean> key1 : keys.entrySet()) {
+                                        if (key1.getKey() == key.getKey())
+                                            break;
+
+                                        mappedKeys.put(key.getKey(), key1.getValue());
+                                    }
+                                }
                             }
-                            else
+                            else if (mappedKeys != null)
                                 mappedKeys.put(key.getKey(), key.getValue());
                         }
                     }
 
                     // Add new future.
-                    add(getAsync(mappedKeys));
+                    add(getAsync(mappedKeys == null ? keys : mappedKeys));
 
                     // Finish this one.
                     return Collections.emptyList();
@@ -288,8 +298,8 @@ public final class GridDhtGetFuture<K, V> extends GridCompoundIdentityFuture<Col
      */
     @SuppressWarnings( {"unchecked", "IfMayBeConditional"})
     private IgniteInternalFuture<Collection<GridCacheEntryInfo>> getAsync(
-        final LinkedHashMap<KeyCacheObject, Boolean> keys)
-    {
+        final Map<KeyCacheObject, Boolean> keys
+    ) {
         if (F.isEmpty(keys))
             return new GridFinishedFuture<Collection<GridCacheEntryInfo>>(
                 Collections.<GridCacheEntryInfo>emptyList());

http://git-wip-us.apache.org/repos/asf/ignite/blob/3289cc1f/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridPartitionedSingleGetFuture.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridPartitionedSingleGetFuture.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridPartitionedSingleGetFuture.java
index f276cac..5923517 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridPartitionedSingleGetFuture.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridPartitionedSingleGetFuture.java
@@ -18,8 +18,10 @@
 package org.apache.ignite.internal.processors.cache.distributed.dht;
 
 import java.util.Collection;
+import java.util.Collections;
 import java.util.LinkedHashMap;
 import java.util.List;
+import java.util.Map;
 import java.util.UUID;
 import java.util.concurrent.atomic.AtomicReference;
 import org.apache.ignite.IgniteCheckedException;
@@ -198,10 +200,11 @@ public class GridPartitionedSingleGetFuture extends GridFutureAdapter<Object> im
             return;
         }
 
-        if (node.isLocal()) {
-            LinkedHashMap<KeyCacheObject, Boolean> map = U.newLinkedHashMap(1);
+        if (isDone())
+            return;
 
-            map.put(key, false);
+        if (node.isLocal()) {
+            Map<KeyCacheObject, Boolean> map = Collections.singletonMap(key, false);
 
             final GridDhtFuture<Collection<GridCacheEntryInfo>> fut = cctx.dht().getDhtAsync(node.id(),
                 -1,

http://git-wip-us.apache.org/repos/asf/ignite/blob/3289cc1f/modules/core/src/main/java/org/apache/ignite/internal/util/future/GridCompoundFuture.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/future/GridCompoundFuture.java b/modules/core/src/main/java/org/apache/ignite/internal/util/future/GridCompoundFuture.java
index 5f0d411..31dbbba 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/util/future/GridCompoundFuture.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/util/future/GridCompoundFuture.java
@@ -55,6 +55,9 @@ public class GridCompoundFuture<T, R> extends GridFutureAdapter<R> {
     /** Futures. */
     protected final ArrayList<IgniteInternalFuture<T>> futs = new ArrayList<>();
 
+    /** */
+    private final Listener lsnr = new Listener();
+
     /** Reducer. */
     @GridToStringInclude
     private IgniteReducer<T, R> rdc;
@@ -201,7 +204,7 @@ public class GridCompoundFuture<T, R> extends GridFutureAdapter<R> {
             futs.add(fut);
         }
 
-        fut.listen(new Listener());
+        fut.listen(lsnr);
 
         if (isCancelled()) {
             try {

http://git-wip-us.apache.org/repos/asf/ignite/blob/3289cc1f/modules/core/src/main/java/org/apache/ignite/internal/util/future/GridFutureAdapter.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/util/future/GridFutureAdapter.java b/modules/core/src/main/java/org/apache/ignite/internal/util/future/GridFutureAdapter.java
index 0f65d33..a1720d5 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/util/future/GridFutureAdapter.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/util/future/GridFutureAdapter.java
@@ -494,4 +494,4 @@ public class GridFutureAdapter<R> extends AbstractQueuedSynchronizer implements
             return "ChainFuture [orig=" + fut + ", doneCb=" + doneCb + ']';
         }
     }
-}
\ No newline at end of file
+}