Added putAll benchmarks.
Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/5304e6ee Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/5304e6ee Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/5304e6ee Branch: refs/heads/ignite-1155_1 Commit: 5304e6ee47970c6989784a2ab47f875437883cfa Parents: f22de3e Author: nikolay_tikhonov <ntikho...@gridgain.com> Authored: Mon Jul 27 13:46:47 2015 +0300 Committer: nikolay_tikhonov <ntikho...@gridgain.com> Committed: Mon Jul 27 13:46:47 2015 +0300 ---------------------------------------------------------------------- modules/yardstick/config/benchmark.properties | 6 +- .../yardstick/IgniteBenchmarkArguments.java | 22 +++++++ .../yardstick/cache/IgnitePutAllBenchmark.java | 67 +++++++++++++++++++ .../cache/IgnitePutAllTxBenchmark.java | 68 ++++++++++++++++++++ 4 files changed, 162 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/5304e6ee/modules/yardstick/config/benchmark.properties ---------------------------------------------------------------------- diff --git a/modules/yardstick/config/benchmark.properties b/modules/yardstick/config/benchmark.properties index edda9ee..d691f1e 100644 --- a/modules/yardstick/config/benchmark.properties +++ b/modules/yardstick/config/benchmark.properties @@ -86,5 +86,9 @@ CONFIGS="\ -cfg ${SCRIPT_DIR}/../config/ignite-localhost-config.xml -nn ${nodesNum} -b 1 -w 60 -d 300 -t 64 -sm PRIMARY_SYNC -dn IgnitePutTxOffHeapValuesBenchmark -sn IgniteNode -ds ${ver}tx-put-offheap-val-1-backup,\ -cfg ${SCRIPT_DIR}/../config/ignite-localhost-config.xml -nn ${nodesNum} -b 1 -w 60 -d 300 -t 64 -sm PRIMARY_SYNC -dn IgniteSqlQueryOffHeapBenchmark -sn IgniteNode -ds ${ver}sql-query-offheap-1-backup,\ -cfg ${SCRIPT_DIR}/../config/ignite-localhost-config.xml -nn ${nodesNum} -b 1 -w 60 -d 300 -t 64 -sm PRIMARY_SYNC -dn IgniteSqlQueryJoinOffHeapBenchmark -sn IgniteNode -ds ${ver}sql-query-join-offheap-1-backup,\ --cfg ${SCRIPT_DIR}/../config/ignite-localhost-config.xml -nn ${nodesNum} -b 1 -w 60 -d 300 -t 64 -sm PRIMARY_SYNC -dn IgniteSqlQueryPutOffHeapBenchmark -sn IgniteNode -ds ${ver}sql-query-put-offheap-1-backup\ +-cfg ${SCRIPT_DIR}/../config/ignite-localhost-config.xml -nn ${nodesNum} -b 1 -w 60 -d 300 -t 64 -sm PRIMARY_SYNC -dn IgniteSqlQueryPutOffHeapBenchmark -sn IgniteNode -ds ${ver}sql-query-put-offheap-1-backup,\ +-cfg ${SCRIPT_DIR}/../config/ignite-localhost-config.xml -nn ${nodesNum} -b 1 -w 60 -d 300 -t 64 -bs 1000 -sm PRIMARY_SYNC -dn IgnitePutAllBenchmark -sn IgniteNode -ds ${ver}atomic-putAll-1-backup,\ +-cfg ${SCRIPT_DIR}/../config/ignite-localhost-config.xml -nn ${nodesNum} -b 1 -w 60 -d 300 -t 64 -bs 1000 -col -sm PRIMARY_SYNC -dn IgnitePutAllBenchmark -sn IgniteNode -ds ${ver}atomic-collocated-putAll-1-backup,\ +-cfg ${SCRIPT_DIR}/../config/ignite-localhost-config.xml -nn ${nodesNum} -b 1 -w 60 -d 300 -t 64 -bs 1000 -sm PRIMARY_SYNC -dn IgnitePutAllTxBenchmark -sn IgniteNode -ds ${ver}atomic-putAll-tx-1-backup,\ +-cfg ${SCRIPT_DIR}/../config/ignite-localhost-config.xml -nn ${nodesNum} -b 1 -w 60 -d 300 -t 64 -bs 1000 -col -sm PRIMARY_SYNC -dn IgnitePutAllTxBenchmark -sn IgniteNode -ds ${ver}atomic-collocated-putAll-tx-1-backup\ " http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/5304e6ee/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 b21bed3..1562b26 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 @@ -98,6 +98,14 @@ public class IgniteBenchmarkArguments { @Parameter(names = {"-wb", "--writeBehind"}, description = "Enable or disable writeBehind for cache store") private boolean writeBehind; + /** */ + @Parameter(names = {"-bs", "--batchSize"}, description = "Batch size") + private int batch = 500; + + /** */ + @Parameter(names = {"-col", "--collocated"}, description = "Collocated") + private boolean collocated; + /** * @return Transaction concurrency. */ @@ -232,6 +240,20 @@ public class IgniteBenchmarkArguments { } /** + * @return Batch size. + */ + public int batch() { + return batch; + } + + /** + * @return Collocated. + */ + public boolean collocated() { + return collocated; + } + + /** * @return Description. */ public String description() { http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/5304e6ee/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 new file mode 100644 index 0000000..6b30875 --- /dev/null +++ b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgnitePutAllBenchmark.java @@ -0,0 +1,67 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.ignite.yardstick.cache; + +import org.apache.ignite.*; +import org.apache.ignite.cache.affinity.*; +import org.apache.ignite.cluster.*; +import org.yardstickframework.*; + +import java.util.*; + +/** + * Ignite benchmark that performs putAll operations. + */ +public class IgnitePutAllBenchmark extends IgniteCacheAbstractBenchmark { + /** Affinity mapper. */ + private Affinity<Integer> aff; + + /** {@inheritDoc} */ + @Override public void setUp(BenchmarkConfiguration cfg) throws Exception { + super.setUp(cfg); + + aff = ignite().affinity("atomic"); + } + + /** {@inheritDoc} */ + @Override public boolean test(Map<Object, Object> ctx) throws Exception { + SortedMap<Integer, Integer> vals = new TreeMap<>(); + + ClusterNode node = args.collocated() ? aff.mapKeyToNode(nextRandom(args.range())) : null; + + for (int i = 0; i < args.batch(); ) { + int key = nextRandom(args.range()); + + if (args.collocated() && !aff.isPrimary(node, key)) + continue; + + ++i; + + vals.put(key, key); + } + + cache.putAll(vals); + + return true; + } + + /** {@inheritDoc} */ + @Override protected IgniteCache<Integer, Object> cache() { + return ignite().cache("atomic"); + } +} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/5304e6ee/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 new file mode 100644 index 0000000..01890c9 --- /dev/null +++ b/modules/yardstick/src/main/java/org/apache/ignite/yardstick/cache/IgnitePutAllTxBenchmark.java @@ -0,0 +1,68 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.ignite.yardstick.cache; + +import org.apache.ignite.*; +import org.apache.ignite.cache.affinity.*; +import org.apache.ignite.cluster.*; +import org.yardstickframework.*; + +import java.util.*; + +/** + * Ignite benchmark that performs transactional putAll operations. + */ +public class IgnitePutAllTxBenchmark extends IgniteCacheAbstractBenchmark { + /** 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 { + SortedMap<Integer, Integer> vals = new TreeMap<>(); + + ClusterNode node = args.collocated() ? aff.mapKeyToNode(nextRandom(args.range())) : null; + + for (int i = 0; i < args.batch(); ) { + int key = nextRandom(args.range()); + + if (args.collocated() && !aff.isPrimary(node, key)) + continue; + + ++i; + + vals.put(key, key); + } + + // Implicit transaction is used. + cache.putAll(vals); + + return true; + } + + /** {@inheritDoc} */ + @Override protected IgniteCache<Integer, Object> cache() { + return ignite().cache("tx"); + } +}