ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From yzhda...@apache.org
Subject [6/6] ignite git commit: Debugging slowdowns
Date Mon, 02 Nov 2015 10:45:01 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/b811c8da
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/b811c8da
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/b811c8da

Branch: refs/heads/ignite-1.4-slow-server-debug
Commit: b811c8da025dc70aeaa52d46ee425c688123b4a6
Parents: 7a5b0e2
Author: Yakov Zhdanov <yzhdanov@gridgain.com>
Authored: Mon Nov 2 13:44:35 2015 +0300
Committer: Yakov Zhdanov <yzhdanov@gridgain.com>
Committed: Mon Nov 2 13:44:35 2015 +0300

----------------------------------------------------------------------
 .../java/org/apache/ignite/internal/Bench.java  | 101 ++++++++++++++++++-
 .../managers/communication/GridIoMessage.java   |   4 +-
 2 files changed, 98 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/b811c8da/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 399e079..f363a34 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
@@ -17,21 +17,29 @@
 
 package org.apache.ignite.internal;
 
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ThreadLocalRandom;
+import java.util.concurrent.atomic.AtomicInteger;
+import java.util.concurrent.atomic.AtomicLong;
 import org.apache.ignite.Ignite;
 import org.apache.ignite.IgniteCache;
+import org.apache.ignite.IgniteException;
 import org.apache.ignite.Ignition;
 import org.apache.ignite.cache.CacheAtomicityMode;
 import org.apache.ignite.cache.CacheRebalanceMode;
 import org.apache.ignite.cache.CacheWriteSynchronizationMode;
+import org.apache.ignite.cluster.ClusterNode;
 import org.apache.ignite.configuration.CacheConfiguration;
 import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.internal.managers.communication.GridIoMessage;
 import org.apache.ignite.internal.util.typedef.internal.U;
+import org.apache.ignite.lang.IgniteInClosure;
+import org.apache.ignite.plugin.extensions.communication.Message;
+import org.apache.ignite.spi.IgniteSpiException;
 import org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi;
 import org.jsr166.LongAdder8;
 
-import java.util.concurrent.ThreadLocalRandom;
-import java.util.concurrent.atomic.AtomicLong;
-
 /**
  *
  */
@@ -45,7 +53,7 @@ public class Bench {
             false));
 
         final boolean client = false;
-        final boolean forceRnd = false;
+        final boolean forceRnd = true;
 
         final Ignite ignite = Ignition.start(config("0",
             client));
@@ -106,6 +114,89 @@ public class Bench {
 
         commSpi.setSharedMemoryPort(-1);
 
-        return new IgniteConfiguration().setGridName(name).setLocalHost("127.0.0.1").setClientMode(client).setCommunicationSpi(commSpi);
+        return new IgniteConfiguration()
+            .setGridName(name)
+            .setLocalHost("127.0.0.1")
+            .setClientMode(client)
+            .setCommunicationSpi(new CommunicationSpi());
+    }
+
+    /**
+     *
+     */
+    private static class CommunicationSpi extends TcpCommunicationSpi {
+        /** */
+        private final Map<Byte, AtomicInteger> msgMap = new ConcurrentHashMap<>();
+
+        /** */
+        @Override public void spiStart(final String gridName) throws IgniteSpiException {
+            super.spiStart(gridName);
+
+            Thread thread = new Thread(new Runnable() {
+                @Override public void run() {
+                    for (;;) {
+                        try {
+                            Thread.sleep(1000);
+                        }
+                        catch (InterruptedException e) {
+                            e.printStackTrace();
+                        }
+
+                        synchronized (Bench.class) {
+                            U.debug("\nGrid: " + gridName);
+
+                            for (Map.Entry<Byte, AtomicInteger> e : msgMap.entrySet())
+                                U.debug("\t" + e.getKey() + " : " + e.getValue().get());
+                        }
+
+                        msgMap.clear();
+                    }
+                }
+            });
+
+            thread.setDaemon(true);
+
+            thread.start();
+        }
+
+        /** {@inheritDoc} */
+        @Override public void sendMessage(
+            ClusterNode node,
+            Message msg
+        ) throws IgniteSpiException {
+            sendMessage(
+                node,
+                msg,
+                null);
+        }
+
+        /** {@inheritDoc} */
+        @Override public void sendMessage(
+            ClusterNode node,
+            Message msg,
+            IgniteInClosure<IgniteException> ackClosure
+        ) throws IgniteSpiException {
+            GridIoMessage gridIoMsg = (GridIoMessage)msg;
+
+            Message unwrappedMsg = gridIoMsg.message();
+
+            AtomicInteger cnt = msgMap.get(unwrappedMsg.directType());
+
+            if (cnt == null)
+                msgMap.put(unwrappedMsg.directType(), cnt = new AtomicInteger());
+
+            if (shit && unwrappedMsg.directType() == 56) {
+                cnt.decrementAndGet();
+
+                return;
+            }
+
+            cnt.incrementAndGet();
+
+            super.sendMessage(
+                node,
+                msg,
+                ackClosure);
+        }
     }
 }

http://git-wip-us.apache.org/repos/asf/ignite/blob/b811c8da/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoMessage.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoMessage.java
b/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoMessage.java
index c83a281..cb19ba0 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoMessage.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoMessage.java
@@ -143,7 +143,7 @@ public class GridIoMessage implements Message {
     /**
      * @return Message.
      */
-    public Object message() {
+    public Message message() {
         return msg;
     }
 
@@ -320,4 +320,4 @@ public class GridIoMessage implements Message {
     @Override public String toString() {
         return S.toString(GridIoMessage.class, this);
     }
-}
\ No newline at end of file
+}


Mime
View raw message