Return-Path: X-Original-To: apmail-ignite-commits-archive@minotaur.apache.org Delivered-To: apmail-ignite-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 62BE417588 for ; Thu, 29 Oct 2015 09:02:10 +0000 (UTC) Received: (qmail 1728 invoked by uid 500); 29 Oct 2015 09:02:10 -0000 Delivered-To: apmail-ignite-commits-archive@ignite.apache.org Received: (qmail 1631 invoked by uid 500); 29 Oct 2015 09:02:10 -0000 Mailing-List: contact commits-help@ignite.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@ignite.apache.org Delivered-To: mailing list commits@ignite.apache.org Received: (qmail 1346 invoked by uid 99); 29 Oct 2015 09:02:10 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 29 Oct 2015 09:02:10 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 1C334E3919; Thu, 29 Oct 2015 09:02:10 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: vozerov@apache.org To: commits@ignite.apache.org Date: Thu, 29 Oct 2015 09:02:17 -0000 Message-Id: In-Reply-To: References: X-Mailer: ASF-Git Admin Mailer Subject: [09/49] ignite git commit: Added --keysPerThread parameter for putAll benchmark. Added --keysPerThread parameter for putAll benchmark. Project: http://git-wip-us.apache.org/repos/asf/ignite/repo Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/15cc1bdb Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/15cc1bdb Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/15cc1bdb Branch: refs/heads/ignite-1282 Commit: 15cc1bdb0b35175b79487481966ad9e180927d84 Parents: e6e475c Author: sboikov Authored: Mon Oct 26 14:11:55 2015 +0300 Committer: sboikov Committed: Mon Oct 26 14:11:55 2015 +0300 ---------------------------------------------------------------------- .../yardstick/IgniteBenchmarkArguments.java | 11 ++++ .../cache/IgniteCacheAbstractBenchmark.java | 63 ++++++++++++++++++++ .../cache/IgnitePutAllTxBenchmark.java | 6 +- 3 files changed, 78 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ignite/blob/15cc1bdb/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 6e9059d..792d366 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 @@ -112,6 +112,10 @@ public class IgniteBenchmarkArguments { @Parameter(names = {"-jdbc", "--jdbcUrl"}, description = "JDBC url") private String jdbcUrl; + /** */ + @Parameter(names = {"-kpt", "--keysPerThread"}, description = "Use not intersecting keys in putAll benchmark") + private boolean keysPerThread; + /** * @return JDBC url. */ @@ -274,6 +278,13 @@ public class IgniteBenchmarkArguments { (orderMode == null ? "" : "-wom=" + orderMode) + "-txc=" + txConcurrency; } + /** + * @return {@code True} if use not intersecting keys in putAll benchmark. + */ + public boolean keysPerThread() { + return keysPerThread; + } + /** {@inheritDoc} */ @Override public String toString() { return GridToStringBuilder.toString(IgniteBenchmarkArguments.class, this); http://git-wip-us.apache.org/repos/asf/ignite/blob/15cc1bdb/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgniteCacheAbstractBenchmark.java ---------------------------------------------------------------------- diff --git a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgniteCacheAbstractBenchmark.java b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgniteCacheAbstractBenchmark.java index 7b350c3..1260f9c 100644 --- a/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgniteCacheAbstractBenchmark.java +++ b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgniteCacheAbstractBenchmark.java @@ -17,9 +17,12 @@ package org.apache.ignite.yardstick.cache; +import java.util.concurrent.ThreadLocalRandom; +import java.util.concurrent.atomic.AtomicInteger; import org.apache.ignite.IgniteCache; import org.apache.ignite.yardstick.IgniteAbstractBenchmark; import org.yardstickframework.BenchmarkConfiguration; +import org.yardstickframework.BenchmarkUtils; /** * Abstract class for Ignite benchmarks which use cache. @@ -28,6 +31,12 @@ public abstract class IgniteCacheAbstractBenchmark extends IgniteAbstractBenchma /** Cache. */ protected IgniteCache cache; + /** */ + private ThreadLocal threadRange = new ThreadLocal<>(); + + /** */ + private AtomicInteger threadIdx = new AtomicInteger(); + /** {@inheritDoc} */ @Override public void setUp(BenchmarkConfiguration cfg) throws Exception { super.setUp(cfg); @@ -36,9 +45,63 @@ public abstract class IgniteCacheAbstractBenchmark extends IgniteAbstractBenchma } /** + * @return Range. + */ + protected final ThreadRange threadRange() { + ThreadRange r = threadRange.get(); + + if (r == null) { + if (args.keysPerThread()) { + int idx = threadIdx.getAndIncrement(); + + int keysPerThread = (int)(args.range() / (float)cfg.threads()); + + int min = keysPerThread * idx; + int max = min + keysPerThread; + + r = new ThreadRange(min, max); + } + else + r = new ThreadRange(0, args.range()); + + BenchmarkUtils.println(cfg, "Initialized thread range [min=" + r.min + ", max=" + r.max + ']'); + + threadRange.set(r); + } + + return r; + } + + /** * Each benchmark must determine which cache will be used. * * @return IgniteCache Cache to use. */ protected abstract IgniteCache cache(); + + /** + * + */ + static class ThreadRange { + /** */ + final int min; + /** */ + final int max; + + /** + * @param min Min. + * @param max Max. + */ + private ThreadRange(int min, int max) { + this.min = min; + this.max = max; + } + + /** + * @return Next random key. + */ + int nextRandom() { + return ThreadLocalRandom.current().nextInt(min, max); + } + } } \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ignite/blob/15cc1bdb/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 dc8e3f8..32d5b02 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 @@ -41,12 +41,14 @@ public class IgnitePutAllTxBenchmark extends IgniteCacheAbstractBenchmark { /** {@inheritDoc} */ @Override public boolean test(Map ctx) throws Exception { + ThreadRange r = threadRange(); + SortedMap vals = new TreeMap<>(); - ClusterNode node = args.collocated() ? aff.mapKeyToNode(nextRandom(args.range())) : null; + ClusterNode node = args.collocated() ? aff.mapKeyToNode(r.nextRandom()) : null; for (int i = 0; i < args.batch(); ) { - int key = nextRandom(args.range()); + int key = r.nextRandom(); if (args.collocated() && !aff.isPrimary(node, key)) continue;