ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From yzhda...@apache.org
Subject ignite git commit: put all benchmark - added striping and pregenerated maps
Date Thu, 02 Mar 2017 12:37:25 GMT
Repository: ignite
Updated Branches:
  refs/heads/ignite-3477 c6df06030 -> 76cd44d6f


put all benchmark - added striping and pregenerated maps


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

Branch: refs/heads/ignite-3477
Commit: 76cd44d6fc8a195b2a20016c144836e684330b40
Parents: c6df060
Author: Yakov Zhdanov <yzhdanov@gridgain.com>
Authored: Thu Mar 2 15:01:50 2017 +0300
Committer: Yakov Zhdanov <yzhdanov@gridgain.com>
Committed: Thu Mar 2 15:01:50 2017 +0300

----------------------------------------------------------------------
 .../yardstick/IgniteAbstractBenchmark.java      |  6 ++
 .../yardstick/IgniteBenchmarkArguments.java     | 11 +++
 .../yardstick/cache/IgnitePutAllBenchmark.java  | 95 +++++++++++++++++---
 .../cache/IgnitePutAllTxBenchmark.java          | 43 +--------
 4 files changed, 103 insertions(+), 52 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/76cd44d6/modules/yardstick/src/main/java/org/apache/ignite/yardstick/IgniteAbstractBenchmark.java
----------------------------------------------------------------------
diff --git a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/IgniteAbstractBenchmark.java
b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/IgniteAbstractBenchmark.java
index ba815fe..5aec308 100644
--- a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/IgniteAbstractBenchmark.java
+++ b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/IgniteAbstractBenchmark.java
@@ -20,6 +20,7 @@ package org.apache.ignite.yardstick;
 import java.util.concurrent.CountDownLatch;
 import java.util.concurrent.ThreadLocalRandom;
 import org.apache.ignite.Ignite;
+import org.apache.ignite.IgniteLogger;
 import org.apache.ignite.IgniteState;
 import org.apache.ignite.Ignition;
 import org.apache.ignite.events.Event;
@@ -61,6 +62,11 @@ public abstract class IgniteAbstractBenchmark extends BenchmarkDriverAdapter
{
             node = new IgniteNode(args.isClientOnly() && !args.isNearCache(), Ignition.ignite());
 
         waitForNodes();
+
+        IgniteLogger log = ignite().log();
+
+        if (log.isInfoEnabled())
+            log.info("Benchmark arguments: " + args);
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/ignite/blob/76cd44d6/modules/yardstick/src/main/java/org/apache/ignite/yardstick/IgniteBenchmarkArguments.java
----------------------------------------------------------------------
diff --git a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/IgniteBenchmarkArguments.java
b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/IgniteBenchmarkArguments.java
index fd07841..a1c5087 100644
--- a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/IgniteBenchmarkArguments.java
+++ b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/IgniteBenchmarkArguments.java
@@ -126,6 +126,10 @@ public class IgniteBenchmarkArguments {
     private boolean collocated;
 
     /** */
+    @Parameter(names = {"-stripe", "--singleStripe"}, description = "Generate keys belonging
to single stripe per node")
+    private boolean singleStripe;
+
+    /** */
     @Parameter(names = {"-jdbc", "--jdbcUrl"}, description = "JDBC url")
     private String jdbcUrl;
 
@@ -381,6 +385,13 @@ public class IgniteBenchmarkArguments {
     }
 
     /**
+     * @return Generate keys for single stripe per node.
+     */
+    public boolean singleStripe() {
+        return singleStripe;
+    }
+
+    /**
      * @return Delay in second which used in nodes restart algorithm.
      */
     public int restartDelay() {

http://git-wip-us.apache.org/repos/asf/ignite/blob/76cd44d6/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgnitePutAllBenchmark.java
----------------------------------------------------------------------
diff --git a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgnitePutAllBenchmark.java
b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgnitePutAllBenchmark.java
index 8cd2347..33aa205 100644
--- a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgnitePutAllBenchmark.java
+++ b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgnitePutAllBenchmark.java
@@ -17,43 +17,118 @@
 
 package org.apache.ignite.yardstick.cache;
 
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
 import java.util.Map;
-import java.util.SortedMap;
 import java.util.TreeMap;
 import org.apache.ignite.IgniteCache;
+import org.apache.ignite.IgniteLogger;
 import org.apache.ignite.cache.affinity.Affinity;
 import org.apache.ignite.cluster.ClusterNode;
+import org.apache.ignite.internal.util.typedef.internal.U;
 import org.yardstickframework.BenchmarkConfiguration;
 
 /**
  * Ignite benchmark that performs putAll operations.
  */
 public class IgnitePutAllBenchmark extends IgniteCacheAbstractBenchmark<Integer, Object>
{
+    /** */
+    private static final Integer PUT_MAPS_KEY = 2048;
+
+    /** */
+    private static final Integer PUT_MAPS_CNT = 256;
+
     /** Affinity mapper. */
     private Affinity<Integer> aff;
 
+    /** */
+    private int srvrCnt;
+
+    /** */
+    private int stripesCnt;
+
     /** {@inheritDoc} */
     @Override public void setUp(BenchmarkConfiguration cfg) throws Exception {
         super.setUp(cfg);
 
-        aff = ignite().affinity("atomic");
+        aff = ignite().affinity(cache().getName());
+
+        Collection<ClusterNode> nodes = ignite().cluster().forServers().nodes();
+
+        stripesCnt = ignite().cluster().forServers().forRandom().metrics().getTotalCpus();
+
+        srvrCnt = nodes.size();
+
+        IgniteLogger log = ignite().log();
+
+        if (log.isInfoEnabled())
+            log.info("Servers info [srvrsCnt=" + srvrCnt + ", stripesCnt=" + stripesCnt +
']');
     }
 
     /** {@inheritDoc} */
     @Override public boolean test(Map<Object, Object> ctx) throws Exception {
-        SortedMap<Integer, Integer> vals = new TreeMap<>();
+        List<Map<Integer, Integer>> putMaps = (List<Map<Integer, Integer>>)ctx.get(PUT_MAPS_KEY);
+
+        if (putMaps == null) {
+            putMaps = new ArrayList<>(PUT_MAPS_CNT);
+
+            ctx.put(PUT_MAPS_KEY, putMaps);
+        }
+
+        Map<Integer, Integer> vals;
+
+        if (putMaps.size() == PUT_MAPS_CNT)
+            vals = putMaps.get(nextRandom(PUT_MAPS_CNT));
+        else {
+            vals = new TreeMap<>();
+
+            ClusterNode node = args.collocated() ? aff.mapKeyToNode(nextRandom(args.range()))
: null;
+
+            Map<ClusterNode, Integer> stripesMap = null;
+
+            if (args.singleStripe())
+                stripesMap = U.newHashMap(srvrCnt);
+
+            for (; vals.size() < args.batch(); ) {
+                int key = nextRandom(args.range());
+
+                if (args.collocated() && !aff.isPrimary(
+                    node,
+                    key))
+                    continue;
+
+                if (args.singleStripe()) {
+                    int part = aff.partition(key);
+
+                    ClusterNode node0 = node != null ? node : aff.mapPartitionToNode(part);
+
+                    Integer stripe0 = stripesMap.get(node0);
+                    int stripe = part % stripesCnt;
 
-        ClusterNode node = args.collocated() ? aff.mapKeyToNode(nextRandom(args.range()))
: null;
+                    if (stripe0 != null) {
+                        if (stripe0 != stripe)
+                            continue;
+                    }
+                    else
+                        stripesMap.put(
+                            node0,
+                            stripe);
+                }
 
-        for (int i = 0; i < args.batch(); ) {
-            int key = nextRandom(args.range());
+                vals.put(
+                    key,
+                    key);
+            }
 
-            if (args.collocated() && !aff.isPrimary(node, key))
-                continue;
+            putMaps.add(vals);
 
-            ++i;
+            if (putMaps.size() == PUT_MAPS_CNT) {
+                IgniteLogger log = ignite().log();
 
-            vals.put(key, key);
+                if (log.isInfoEnabled())
+                    log.info("Put maps set generated.");
+            }
         }
 
         cache.putAll(vals);

http://git-wip-us.apache.org/repos/asf/ignite/blob/76cd44d6/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgnitePutAllTxBenchmark.java
----------------------------------------------------------------------
diff --git a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgnitePutAllTxBenchmark.java
b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgnitePutAllTxBenchmark.java
index 63faa2f..d701314 100644
--- a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgnitePutAllTxBenchmark.java
+++ b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgnitePutAllTxBenchmark.java
@@ -17,53 +17,12 @@
 
 package org.apache.ignite.yardstick.cache;
 
-import java.util.Map;
-import java.util.SortedMap;
-import java.util.TreeMap;
 import org.apache.ignite.IgniteCache;
-import org.apache.ignite.cache.affinity.Affinity;
-import org.apache.ignite.cluster.ClusterNode;
-import org.yardstickframework.BenchmarkConfiguration;
 
 /**
  * Ignite benchmark that performs transactional putAll operations.
  */
-public class IgnitePutAllTxBenchmark extends IgniteCacheAbstractBenchmark<Integer, Object>
{
-    /** Affinity mapper. */
-    private Affinity<Integer> aff;
-
-    /** {@inheritDoc} */
-    @Override public void setUp(BenchmarkConfiguration cfg) throws Exception {
-        super.setUp(cfg);
-
-        aff = ignite().affinity("tx");
-    }
-
-    /** {@inheritDoc} */
-    @Override public boolean test(Map<Object, Object> ctx) throws Exception {
-        ThreadRange r = threadRange();
-
-        SortedMap<Integer, Integer> vals = new TreeMap<>();
-
-        ClusterNode node = args.collocated() ? aff.mapKeyToNode(r.nextRandom()) : null;
-
-        for (int i = 0; i < args.batch(); ) {
-            int key = r.nextRandom();
-
-            if (args.collocated() && !aff.isPrimary(node, key))
-                continue;
-
-            ++i;
-
-            vals.put(key, key);
-        }
-
-        // Implicit transaction is used.
-        cache.putAll(vals);
-
-        return true;
-    }
-
+public class IgnitePutAllTxBenchmark extends IgnitePutAllBenchmark {
     /** {@inheritDoc} */
     @Override protected IgniteCache<Integer, Object> cache() {
         return ignite().cache("tx");


Mime
View raw message