This is an automated email from the ASF dual-hosted git repository. jbarrett pushed a commit to branch develop in repository https://gitbox.apache.org/repos/asf/geode-benchmarks.git
The following commit(s) were added to refs/heads/develop by this push: new 3ac8f26 Adds putAll benchmarks (#79) 3ac8f26 is described below commit 3ac8f2693d33cbf0138e98dce21cbe2275d82fed Author: Jacob Barrett <jbarr...@pivotal.io> AuthorDate: Tue Jul 2 12:50:29 2019 -0700 Adds putAll benchmarks (#79) --- .../apache/geode/benchmark/tasks/PutAllTask.java | 62 +++++++++++++++++++++ .../tests/PartitionedPutAllBenchmark.java | 65 ++++++++++++++++++++++ .../benchmark/tests/ReplicatedPutAllBenchmark.java | 65 ++++++++++++++++++++++ 3 files changed, 192 insertions(+) diff --git a/geode-benchmarks/src/main/java/org/apache/geode/benchmark/tasks/PutAllTask.java b/geode-benchmarks/src/main/java/org/apache/geode/benchmark/tasks/PutAllTask.java new file mode 100644 index 0000000..67b30c6 --- /dev/null +++ b/geode-benchmarks/src/main/java/org/apache/geode/benchmark/tasks/PutAllTask.java @@ -0,0 +1,62 @@ +/* + * 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.geode.benchmark.tasks; + +import java.io.Serializable; +import java.util.HashMap; +import java.util.Map; +import java.util.concurrent.ThreadLocalRandom; + +import benchmark.geode.data.Portfolio; +import org.yardstickframework.BenchmarkConfiguration; +import org.yardstickframework.BenchmarkDriverAdapter; + +import org.apache.geode.cache.Region; +import org.apache.geode.cache.client.ClientCache; +import org.apache.geode.cache.client.ClientCacheFactory; + +public class PutAllTask extends BenchmarkDriverAdapter implements Serializable { + + private final long keyRange; + private final int batchSize; + + private Region<Object, Object> region; + + public PutAllTask(long keyRange, int batchSize) { + this.keyRange = keyRange; + this.batchSize = batchSize; + } + + @Override + public void setUp(BenchmarkConfiguration cfg) throws Exception { + super.setUp(cfg); + ClientCache cache = ClientCacheFactory.getAnyInstance(); + region = cache.getRegion("region"); + } + + @Override + public boolean test(Map<Object, Object> ctx) { + long key = ThreadLocalRandom.current().nextLong(0, this.keyRange); + HashMap<Object, Object> batch = new HashMap<>(batchSize); + for (int i = 0; i < batchSize; i++) { + batch.put(key, new Portfolio(key)); + } + region.putAll(batch); + return true; + } +} diff --git a/geode-benchmarks/src/main/java/org/apache/geode/benchmark/tests/PartitionedPutAllBenchmark.java b/geode-benchmarks/src/main/java/org/apache/geode/benchmark/tests/PartitionedPutAllBenchmark.java new file mode 100644 index 0000000..6fbc19c --- /dev/null +++ b/geode-benchmarks/src/main/java/org/apache/geode/benchmark/tests/PartitionedPutAllBenchmark.java @@ -0,0 +1,65 @@ +/* + * 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.geode.benchmark.tests; + +import static org.apache.geode.benchmark.topology.ClientServerTopology.Roles.CLIENT; +import static org.apache.geode.benchmark.topology.ClientServerTopology.Roles.SERVER; + +import org.junit.jupiter.api.Test; + +import org.apache.geode.benchmark.tasks.CreateClientProxyRegion; +import org.apache.geode.benchmark.tasks.CreatePartitionedRegion; +import org.apache.geode.benchmark.tasks.PrePopulateRegion; +import org.apache.geode.benchmark.tasks.PutAllTask; +import org.apache.geode.benchmark.topology.ClientServerTopology; +import org.apache.geode.perftest.PerformanceTest; +import org.apache.geode.perftest.TestConfig; +import org.apache.geode.perftest.TestRunners; + +/** + * Benchmark of putAlls on a partitioned region. + */ +public class PartitionedPutAllBenchmark implements PerformanceTest { + + private long keyRange = 1000000; + + private int batchSize = 1000; + + public PartitionedPutAllBenchmark() {} + + public void setKeyRange(long keyRange) { + this.keyRange = keyRange; + } + + @Test + public void run() throws Exception { + TestRunners.defaultRunner().runTest(this); + } + + @Override + public TestConfig configure() { + TestConfig config = GeodeBenchmark.createConfig(); + config.threads(Runtime.getRuntime().availableProcessors() * 2); + ClientServerTopology.configure(config); + config.before(new CreatePartitionedRegion(), SERVER); + config.before(new CreateClientProxyRegion(), CLIENT); + config.before(new PrePopulateRegion(keyRange), SERVER); + config.workload(new PutAllTask(keyRange, batchSize), CLIENT); + return config; + } +} diff --git a/geode-benchmarks/src/main/java/org/apache/geode/benchmark/tests/ReplicatedPutAllBenchmark.java b/geode-benchmarks/src/main/java/org/apache/geode/benchmark/tests/ReplicatedPutAllBenchmark.java new file mode 100644 index 0000000..2a20717 --- /dev/null +++ b/geode-benchmarks/src/main/java/org/apache/geode/benchmark/tests/ReplicatedPutAllBenchmark.java @@ -0,0 +1,65 @@ +/* + * 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.geode.benchmark.tests; + +import static org.apache.geode.benchmark.topology.ClientServerTopology.Roles.CLIENT; +import static org.apache.geode.benchmark.topology.ClientServerTopology.Roles.SERVER; + +import org.junit.jupiter.api.Test; + +import org.apache.geode.benchmark.tasks.CreateClientProxyRegion; +import org.apache.geode.benchmark.tasks.CreateReplicatedRegion; +import org.apache.geode.benchmark.tasks.PrePopulateRegion; +import org.apache.geode.benchmark.tasks.PutAllTask; +import org.apache.geode.benchmark.topology.ClientServerTopology; +import org.apache.geode.perftest.PerformanceTest; +import org.apache.geode.perftest.TestConfig; +import org.apache.geode.perftest.TestRunners; + +/** + * Benchmark of putAlls on a replicated region. + */ +public class ReplicatedPutAllBenchmark implements PerformanceTest { + + private long keyRange = 1000000; + + private int batchSize = 1000; + + public ReplicatedPutAllBenchmark() {} + + public void setKeyRange(long keyRange) { + this.keyRange = keyRange; + } + + @Test + public void run() throws Exception { + TestRunners.defaultRunner().runTest(this); + } + + @Override + public TestConfig configure() { + TestConfig config = GeodeBenchmark.createConfig(); + config.threads(Runtime.getRuntime().availableProcessors() * 2); + ClientServerTopology.configure(config); + config.before(new CreateReplicatedRegion(), SERVER); + config.before(new CreateClientProxyRegion(), CLIENT); + config.before(new PrePopulateRegion(keyRange), SERVER); + config.workload(new PutAllTask(keyRange, batchSize), CLIENT); + return config; + } +}