Skip to content
Permalink
Browse files
Stabilizes query benchmarks (#104)
* Pre-fill region from client so that all servers have PDX instances
* Change query range and number of threads for query benchmarks
  • Loading branch information
kamilla1201 authored and pivotal-jbarrett committed Sep 5, 2019
1 parent 3ef30a4 commit 237c30342f0e1ac4af6e1589e608c35822e4e521
Showing 14 changed files with 38 additions and 41 deletions.
@@ -61,8 +61,7 @@ task benchmark(type: Test) {
useJUnitPlatform()
testLogging { exceptionFormat = 'full' }

exclude "**/Replicated*QueryBenchmark.class"
exclude "**/PartitionedNonIndexedQueryBenchmark.class"
exclude "**/*NonIndexedQueryBenchmark.class"
exclude "**/*PutAllBenchmark.class"

forkEvery 1
@@ -28,20 +28,18 @@
import org.apache.geode.cache.Region;
import org.apache.geode.cache.client.ClientCache;
import org.apache.geode.cache.client.ClientCacheFactory;
import org.apache.geode.cache.query.FunctionDomainException;
import org.apache.geode.cache.query.NameResolutionException;
import org.apache.geode.cache.query.QueryInvocationTargetException;
import org.apache.geode.cache.query.QueryService;
import org.apache.geode.cache.query.Query;
import org.apache.geode.cache.query.SelectResults;
import org.apache.geode.cache.query.TypeMismatchException;
import org.apache.geode.perftest.jvms.RemoteJVMFactory;

public class OQLQuery extends BenchmarkDriverAdapter implements Serializable {
private static final Logger logger = LoggerFactory.getLogger(RemoteJVMFactory.class);
private Region<Object, Object> region;
private LongRange keyRange;
private long queryRange;
ClientCache cache;
private ClientCache cache;
private Query query;


public OQLQuery(LongRange keyRange, long queryRange) {
this.keyRange = keyRange;
@@ -53,6 +51,8 @@ public void setUp(BenchmarkConfiguration cfg) throws Exception {
super.setUp(cfg);
cache = ClientCacheFactory.getAnyInstance();
region = cache.getRegion("region");
query =
cache.getQueryService().newQuery("SELECT * FROM /region r WHERE r.ID >= $1 AND r.ID < $2");
}

@Override
@@ -72,17 +72,12 @@ private void verifyResults(SelectResults results, long minId, long maxId) throws
long id = ((Portfolio) result).getID();
if (id < minId || id > maxId) {
throw new Exception("Invalid Portfolio object retrieved [min =" + minId + " max =" + maxId
+ "] Portfolio retrieved =" + ((Portfolio) result));
+ ") Portfolio retrieved =" + result);
}
}
}

private SelectResults executeQuery(long minId, long maxId)
throws NameResolutionException, TypeMismatchException, QueryInvocationTargetException,
FunctionDomainException {
QueryService queryService = cache.getQueryService();
return (SelectResults) queryService
.newQuery("SELECT * FROM /region r WHERE r.ID >=" + minId + " AND r.ID <=" + maxId)
.execute();
private SelectResults executeQuery(long minId, long maxId) throws Exception {
return (SelectResults) query.execute(minId, maxId);
}
}
@@ -16,6 +16,7 @@
*/
package org.apache.geode.benchmark.tasks;

import static org.apache.geode.benchmark.topology.ClientServerTopology.Roles.CLIENT;
import static org.apache.geode.benchmark.topology.ClientServerTopology.Roles.LOCATOR;
import static org.apache.geode.benchmark.topology.ClientServerTopology.Roles.SERVER;

@@ -35,11 +36,13 @@
import org.slf4j.LoggerFactory;

import org.apache.geode.benchmark.LongRange;
import org.apache.geode.cache.Cache;
import org.apache.geode.cache.Region;
import org.apache.geode.cache.client.ClientCache;
import org.apache.geode.cache.client.ClientCacheFactory;
import org.apache.geode.perftest.Task;
import org.apache.geode.perftest.TestContext;


public class PrePopulateRegion implements Task {
private static final Logger logger = LoggerFactory.getLogger(PrePopulateRegion.class);

@@ -57,15 +60,15 @@ public PrePopulateRegion(LongRange keyRangeToPrepopulate) {
*/
@Override
public void run(TestContext context) throws InterruptedException {
final Cache serverCache = (Cache) context.getAttribute("SERVER_CACHE");
final Region<Long, Portfolio> region = serverCache.getRegion("region");
final ClientCache cache = ClientCacheFactory.getAnyInstance();
final Region<Long, Portfolio> region = cache.getRegion("region");
final int numLocators = context.getHostsIDsForRole(LOCATOR).size();
final int numServers = context.getHostsIDsForRole(SERVER).size();
final int numClient = context.getHostsIDsForRole(CLIENT).size();
final int jvmID = context.getJvmID();
final int serverIndex = jvmID - numLocators;

run(region, keyRangeToPrepopulate.sliceFor(numServers, serverIndex));
final int clientIndex = jvmID - numLocators - numServers;

run(region, keyRangeToPrepopulate.sliceFor(numClient, clientIndex));
}

void run(final Map<Long, Portfolio> region, final LongRange range) throws InterruptedException {
@@ -46,7 +46,7 @@ public TestConfig configure() {
ClientServerTopology.configure(config);
configureRegion(config);
config.before(new CreateClientProxyRegion(), CLIENT);
config.before(new PrePopulateRegion(getKeyRange()), SERVER);
config.before(new PrePopulateRegion(getKeyRange()), CLIENT);
config.before(new RegisterFunction(new BenchmarkFunction(getKeyRange())), SERVER);
return config;
}
@@ -57,7 +57,7 @@ public TestConfig configure() {
ClientServerTopology.configure(config);
config.before(new CreatePartitionedRegion(), SERVER);
config.before(new CreateClientProxyRegion(), CLIENT);
config.before(new PrePopulateRegion(keyRange), SERVER);
config.before(new PrePopulateRegion(keyRange), CLIENT);
config.workload(new GetTask(keyRange), CLIENT);
return config;

@@ -32,7 +32,7 @@

public class PartitionedIndexedQueryBenchmark implements PerformanceTest {
private LongRange keyRange = new LongRange(0, 500000);
private long queryRange = 1000;
private long queryRange = 100;

public PartitionedIndexedQueryBenchmark() {}

@@ -52,12 +52,12 @@ public void run() throws Exception {
@Override
public TestConfig configure() {
TestConfig config = GeodeBenchmark.createConfig();
config.threads(Runtime.getRuntime().availableProcessors() * 2);
config.threads(Runtime.getRuntime().availableProcessors() * 8);
ClientServerTopology.configure(config);
config.before(new CreatePartitionedRegion(), SERVER);
config.before(new CreateClientProxyRegion(), CLIENT);
config.before(new CreateIndexOnID(), SERVER);
config.before(new PrePopulateRegion(keyRange), SERVER);
config.before(new PrePopulateRegion(keyRange), CLIENT);
config.workload(new OQLQuery(keyRange, queryRange), CLIENT);
return config;
}
@@ -31,7 +31,7 @@

public class PartitionedNonIndexedQueryBenchmark implements PerformanceTest {
private LongRange keyRange = new LongRange(0, 500000);
private long queryRange = 1000;
private long queryRange = 100;

public PartitionedNonIndexedQueryBenchmark() {}

@@ -51,11 +51,11 @@ public void run() throws Exception {
@Override
public TestConfig configure() {
TestConfig config = GeodeBenchmark.createConfig();
config.threads(Runtime.getRuntime().availableProcessors() * 2);
config.threads(Runtime.getRuntime().availableProcessors());
ClientServerTopology.configure(config);
config.before(new CreatePartitionedRegion(), SERVER);
config.before(new CreateClientProxyRegion(), CLIENT);
config.before(new PrePopulateRegion(keyRange), SERVER);
config.before(new PrePopulateRegion(keyRange), CLIENT);
config.workload(new OQLQuery(keyRange, queryRange), CLIENT);
return config;
}
@@ -59,7 +59,7 @@ public TestConfig configure() {
ClientServerTopology.configure(config);
config.before(new CreatePartitionedRegion(), SERVER);
config.before(new CreateClientProxyRegion(), CLIENT);
config.before(new PrePopulateRegion(keyRange), SERVER);
config.before(new PrePopulateRegion(keyRange), CLIENT);
config.workload(new PutAllTask(keyRange, batchSize), CLIENT);
return config;
}
@@ -56,7 +56,7 @@ public TestConfig configure() {
ClientServerTopology.configure(config);
config.before(new CreatePartitionedRegion(), SERVER);
config.before(new CreateClientProxyRegion(), CLIENT);
config.before(new PrePopulateRegion(keyRange), SERVER);
config.before(new PrePopulateRegion(keyRange), CLIENT);
config.workload(new PutTask(keyRange), CLIENT);
return config;

@@ -57,7 +57,7 @@ public TestConfig configure() {
ClientServerTopology.configure(config);
config.before(new CreateReplicatedRegion(), SERVER);
config.before(new CreateClientProxyRegion(), CLIENT);
config.before(new PrePopulateRegion(keyRange), SERVER);
config.before(new PrePopulateRegion(keyRange), CLIENT);
config.workload(new GetTask(keyRange), CLIENT);
return config;

@@ -32,7 +32,7 @@

public class ReplicatedIndexedQueryBenchmark implements PerformanceTest {
private LongRange keyRange = new LongRange(0, 500000);
private long queryRange = 1000;
private long queryRange = 100;

public ReplicatedIndexedQueryBenchmark() {}

@@ -52,12 +52,12 @@ public void run() throws Exception {
@Override
public TestConfig configure() {
TestConfig config = GeodeBenchmark.createConfig();
config.threads(Runtime.getRuntime().availableProcessors() * 2);
config.threads(Runtime.getRuntime().availableProcessors() * 8);
ClientServerTopology.configure(config);
config.before(new CreateReplicatedRegion(), SERVER);
config.before(new CreateClientProxyRegion(), CLIENT);
config.before(new CreateIndexOnID(), SERVER);
config.before(new PrePopulateRegion(keyRange), SERVER);
config.before(new PrePopulateRegion(keyRange), CLIENT);
config.workload(new OQLQuery(keyRange, queryRange), CLIENT);
return config;
}
@@ -31,7 +31,7 @@

public class ReplicatedNonIndexedQueryBenchmark implements PerformanceTest {
private LongRange keyRange = new LongRange(0, 500000);
private long queryRange = 1000;
private long queryRange = 100;

public ReplicatedNonIndexedQueryBenchmark() {}

@@ -51,11 +51,11 @@ public void run() throws Exception {
@Override
public TestConfig configure() {
TestConfig config = GeodeBenchmark.createConfig();
config.threads(Runtime.getRuntime().availableProcessors() * 2);
config.threads(Runtime.getRuntime().availableProcessors());
ClientServerTopology.configure(config);
config.before(new CreateReplicatedRegion(), SERVER);
config.before(new CreateClientProxyRegion(), CLIENT);
config.before(new PrePopulateRegion(keyRange), SERVER);
config.before(new PrePopulateRegion(keyRange), CLIENT);
config.workload(new OQLQuery(keyRange, queryRange), CLIENT);
return config;
}
@@ -59,7 +59,7 @@ public TestConfig configure() {
ClientServerTopology.configure(config);
config.before(new CreateReplicatedRegion(), SERVER);
config.before(new CreateClientProxyRegion(), CLIENT);
config.before(new PrePopulateRegion(keyRange), SERVER);
config.before(new PrePopulateRegion(keyRange), CLIENT);
config.workload(new PutAllTask(keyRange, batchSize), CLIENT);
return config;
}
@@ -56,7 +56,7 @@ public TestConfig configure() {
ClientServerTopology.configure(config);
config.before(new CreateReplicatedRegion(), SERVER);
config.before(new CreateClientProxyRegion(), CLIENT);
config.before(new PrePopulateRegion(keyRange), SERVER);
config.before(new PrePopulateRegion(keyRange), CLIENT);
config.workload(new PutTask(keyRange), CLIENT);
return config;

0 comments on commit 237c303

Please sign in to comment.