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 7DA8218221 for ; Mon, 1 Feb 2016 14:27:52 +0000 (UTC) Received: (qmail 14037 invoked by uid 500); 1 Feb 2016 14:21:09 -0000 Delivered-To: apmail-ignite-commits-archive@ignite.apache.org Received: (qmail 13988 invoked by uid 500); 1 Feb 2016 14:21:09 -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 13973 invoked by uid 99); 1 Feb 2016 14:21:09 -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; Mon, 01 Feb 2016 14:21:09 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 5FEA1DFF85; Mon, 1 Feb 2016 14:21:09 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: ntikhonov@apache.org To: commits@ignite.apache.org Date: Mon, 01 Feb 2016 14:21:09 -0000 Message-Id: <66b493a314e14317b375c96d852d836e@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [01/49] ignite git commit: Added project for benchmarks. Repository: ignite Updated Branches: refs/heads/ignite-2435 acae0a5f6 -> 47bc381b9 Added project for benchmarks. Project: http://git-wip-us.apache.org/repos/asf/ignite/repo Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/4edc7bdd Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/4edc7bdd Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/4edc7bdd Branch: refs/heads/ignite-2435 Commit: 4edc7bdd192624a451c9ed19d4c37f26e4653a33 Parents: c55cc97 Author: vozerov-gridgain Authored: Tue Jan 26 17:50:53 2016 +0300 Committer: vozerov-gridgain Committed: Tue Jan 26 17:50:53 2016 +0300 ---------------------------------------------------------------------- modules/benchmarks/pom.xml | 171 +++++++++++++++++++ .../benchmarks/jmh/cache/PutBenchmark.java | 170 ++++++++++++++++++ .../ignite/benchmarks/model/IntValue.java | 91 ++++++++++ pom.xml | 1 + 4 files changed, 433 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ignite/blob/4edc7bdd/modules/benchmarks/pom.xml ---------------------------------------------------------------------- diff --git a/modules/benchmarks/pom.xml b/modules/benchmarks/pom.xml new file mode 100644 index 0000000..1c4ee58 --- /dev/null +++ b/modules/benchmarks/pom.xml @@ -0,0 +1,171 @@ + + + + + + + 4.0.0 + + + org.apache.ignite + ignite-parent + 1 + ../../parent + + + ignite-benchmarks + 1.5.1.final-SNAPSHOT + http://ignite.apache.org + + + UTF-8 + 1.11.1 + 1.6 + benchmarks + + + + + org.apache.ignite + ignite-core + ${project.version} + + + + org.apache.ignite + ignite-indexing + ${project.version} + + + + org.openjdk.jmh + jmh-core + ${jmh.version} + + + org.openjdk.jmh + jmh-generator-annprocess + ${jmh.version} + provided + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + 3.1 + + ${javac.target} + ${javac.target} + ${javac.target} + + + + org.apache.maven.plugins + maven-jar-plugin + + + + test-jar + + + + + + org.apache.maven.plugins + maven-shade-plugin + 2.2 + + + package + + shade + + + ${uberjar.name} + + + org.openjdk.jmh.Main + + + + + + *:* + + META-INF/*.SF + META-INF/*.DSA + META-INF/*.RSA + + + + + + + + + + + + maven-clean-plugin + 2.5 + + + maven-deploy-plugin + 2.8.1 + + + maven-install-plugin + 2.5.1 + + + maven-jar-plugin + 2.4 + + + maven-javadoc-plugin + 2.9.1 + + + maven-resources-plugin + 2.6 + + + maven-site-plugin + 3.3 + + + maven-source-plugin + 2.2.1 + + + maven-surefire-plugin + 2.17 + + + + + \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ignite/blob/4edc7bdd/modules/benchmarks/src/main/java/org/apache/ignite/benchmarks/jmh/cache/PutBenchmark.java ---------------------------------------------------------------------- diff --git a/modules/benchmarks/src/main/java/org/apache/ignite/benchmarks/jmh/cache/PutBenchmark.java b/modules/benchmarks/src/main/java/org/apache/ignite/benchmarks/jmh/cache/PutBenchmark.java new file mode 100644 index 0000000..8ccaf81 --- /dev/null +++ b/modules/benchmarks/src/main/java/org/apache/ignite/benchmarks/jmh/cache/PutBenchmark.java @@ -0,0 +1,170 @@ +/* + * 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.benchmarks.jmh.cache; + +import org.apache.ignite.Ignite; +import org.apache.ignite.IgniteCache; +import org.apache.ignite.IgniteDataStreamer; +import org.apache.ignite.Ignition; +import org.apache.ignite.benchmarks.model.IntValue; +import org.apache.ignite.cache.CacheAtomicityMode; +import org.apache.ignite.cache.CacheMode; +import org.apache.ignite.cache.CacheRebalanceMode; +import org.apache.ignite.cache.CacheWriteSynchronizationMode; +import org.apache.ignite.configuration.CacheConfiguration; +import org.apache.ignite.configuration.IgniteConfiguration; +import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi; +import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder; +import org.openjdk.jmh.annotations.Benchmark; +import org.openjdk.jmh.annotations.BenchmarkMode; +import org.openjdk.jmh.annotations.Fork; +import org.openjdk.jmh.annotations.Measurement; +import org.openjdk.jmh.annotations.Mode; +import org.openjdk.jmh.annotations.OutputTimeUnit; +import org.openjdk.jmh.annotations.Scope; +import org.openjdk.jmh.annotations.Setup; +import org.openjdk.jmh.annotations.State; +import org.openjdk.jmh.annotations.TearDown; +import org.openjdk.jmh.annotations.Threads; +import org.openjdk.jmh.annotations.Warmup; +import org.openjdk.jmh.runner.Runner; +import org.openjdk.jmh.runner.options.Options; +import org.openjdk.jmh.runner.options.OptionsBuilder; + +import java.util.concurrent.ThreadLocalRandom; +import java.util.concurrent.TimeUnit; + +/** + * Put benchmark. + */ +@SuppressWarnings({"unchecked", "unused", "FieldCanBeLocal"}) +@State(Scope.Benchmark) +@BenchmarkMode(Mode.Throughput) +@OutputTimeUnit(TimeUnit.SECONDS) +@Warmup(iterations = 10) +@Measurement(iterations = 120) +@Fork(1) +public class PutBenchmark { + /** First Ignite instance. */ + private static Ignite ignite1; + + /** Second Ignite instance. */ + private static Ignite ignite2; + + /** Target cache. */ + private static IgniteCache cache1; + + /** Items count. */ + private static final int CNT = 100000; + + /** IP finder shared across nodes. */ + private static final TcpDiscoveryVmIpFinder IP_FINDER = new TcpDiscoveryVmIpFinder(true); + + /** + * Set up routine. + * + * @throws Exception If failed. + */ + @Setup + public static void setup() throws Exception { + ignite1 = Ignition.start(config("node1")); + ignite2 = Ignition.start(config("node2")); + + cache1 = ignite1.cache(null); + + IgniteDataStreamer dataLdr = ignite1.dataStreamer(cache1.getName()); + + for (int i = 0; i < CNT; i++) + dataLdr.addData(i, new IntValue(i)); + + dataLdr.close(); + + System.out.println("Cache populated."); + } + + /** + * Tear down routine. + * + * @throws Exception If failed. + */ + @TearDown + public static void tearDown() throws Exception { + Ignition.stopAll(true); + } + + /** + * Create configuration. + * + * @param gridName Grid name. + * @return Configuration. + */ + private static IgniteConfiguration config(String gridName) { + IgniteConfiguration cfg = new IgniteConfiguration(); + + cfg.setGridName(gridName); + + cfg.setLocalHost("127.0.0.1"); + + TcpDiscoverySpi discoSpi = new TcpDiscoverySpi(); + discoSpi.setIpFinder(IP_FINDER); + cfg.setDiscoverySpi(discoSpi); + + CacheConfiguration cacheCfg = new CacheConfiguration(); + + cacheCfg.setName(null); + cacheCfg.setCacheMode(CacheMode.PARTITIONED); + cacheCfg.setAtomicityMode(CacheAtomicityMode.ATOMIC); + cacheCfg.setWriteSynchronizationMode(CacheWriteSynchronizationMode.PRIMARY_SYNC); + cacheCfg.setRebalanceMode(CacheRebalanceMode.SYNC); + cacheCfg.setBackups(1); + + cfg.setCacheConfiguration(cacheCfg); + + return cfg; + } + + /** + * Test PUT operation. + * + * @throws Exception If failed. + */ + @Benchmark + @Threads(4) + public void testPut() throws Exception { + int key = ThreadLocalRandom.current().nextInt(CNT); + + cache1.put(key, new IntValue(key)); + } + + /** + * Runner. + * + * @param args Arguments. + * @throws Exception If failed. + */ + public static void main(String[] args) throws Exception { + // Use the following additional options to record JFR dump: + // "-XX:+UnlockCommercialFeatures", "-XX:+FlightRecorder", "-XX:StartFlightRecording=delay=20s,duration=60s,filename=ignite-put_bench.jfr" + + String[] jvmArgs = new String[] { "-Xms4g", "-Xmx4g" }; + + Options opts = new OptionsBuilder().include(PutBenchmark.class.getSimpleName()).jvmArgs(jvmArgs).build(); + + new Runner(opts).run(); + } +} http://git-wip-us.apache.org/repos/asf/ignite/blob/4edc7bdd/modules/benchmarks/src/main/java/org/apache/ignite/benchmarks/model/IntValue.java ---------------------------------------------------------------------- diff --git a/modules/benchmarks/src/main/java/org/apache/ignite/benchmarks/model/IntValue.java b/modules/benchmarks/src/main/java/org/apache/ignite/benchmarks/model/IntValue.java new file mode 100644 index 0000000..5d29d33 --- /dev/null +++ b/modules/benchmarks/src/main/java/org/apache/ignite/benchmarks/model/IntValue.java @@ -0,0 +1,91 @@ +/* + * 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.benchmarks.model; + +import org.apache.ignite.binary.BinaryObjectException; +import org.apache.ignite.binary.BinaryReader; +import org.apache.ignite.binary.BinaryWriter; +import org.apache.ignite.binary.Binarylizable; + +import java.io.Externalizable; +import java.io.IOException; +import java.io.ObjectInput; +import java.io.ObjectOutput; + +/** + * Simple wrapped int value. + */ +public class IntValue implements Externalizable, Binarylizable { + /** Value. */ + private int val; + + /** + * Default constructor. + */ + public IntValue() { + // No-op. + } + + /** + * Constructor. + * + * @param val Value. + */ + public IntValue(int val) { + this.val = val; + } + + /** + * @param val Value. + */ + public void value(int val) { + this.val = val; + } + + /** + * @return Value. + */ + public int value() { + return val; + } + + /** {@inheritDoc} */ + @Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException { + val = in.readInt(); + } + + /** {@inheritDoc} */ + @Override public void writeExternal(ObjectOutput out) throws IOException { + out.writeInt(val); + } + + /** {@inheritDoc} */ + @Override public void writeBinary(BinaryWriter writer) throws BinaryObjectException { + writer.writeInt("id", val); + } + + /** {@inheritDoc} */ + @Override public void readBinary(BinaryReader reader) throws BinaryObjectException { + val = reader.readInt("id"); + } + + /** {@inheritDoc} */ + @Override public String toString() { + return "Value [id=" + val + ']'; + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ignite/blob/4edc7bdd/pom.xml ---------------------------------------------------------------------- diff --git a/pom.xml b/pom.xml index 0a74c47..2dd9698 100644 --- a/pom.xml +++ b/pom.xml @@ -84,6 +84,7 @@ modules/osgi-paxlogging modules/osgi-karaf modules/osgi + modules/benchmarks