Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate ReconBench to ElasqlBench #15

Open
wants to merge 6 commits into
base: res/recon/baseline/main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 19 additions & 20 deletions src/main/java/org/elasql/bench/ElasqlBench.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import java.util.logging.Logger;

import org.elasql.bench.benchmarks.micro.ElasqlMicroBenchmark;
import org.elasql.bench.benchmarks.recon.ElasqlReconBenchmark;
import org.elasql.bench.benchmarks.recon.ReconBenchmark;
import org.elasql.bench.benchmarks.tpcc.ElasqlTpccBenchmark;
import org.elasql.bench.benchmarks.tpce.ElasqlTpceBenchmark;
import org.elasql.bench.benchmarks.ycsb.ElasqlYcsbBenchmark;
Expand All @@ -19,7 +19,6 @@
import org.elasql.server.Elasql.ServiceType;
import org.vanilladb.bench.BenchTransactionType;
import org.vanilladb.bench.Benchmark;
import org.vanilladb.bench.BenchmarkerParameters;
import org.vanilladb.bench.StatisticMgr;
import org.vanilladb.bench.remote.SutConnection;
import org.vanilladb.bench.remote.SutDriver;
Expand Down Expand Up @@ -77,13 +76,15 @@ public void benchmark() {
logger.info("database check passed.");

if (logger.isLoggable(Level.INFO))
logger.info("creating " + BenchmarkerParameters.NUM_RTES + " emulators...");
logger.info("creating " + ElasqlBenchParameters.NUM_RTES + " emulators...");

int rteCount = benchmarker.getNumOfRTEs();
RemoteTerminalEmulator<?>[] emulators = new RemoteTerminalEmulator[rteCount];
emulators[0] = benchmarker.createRte(conn, statMgr); // Reuse the connection
emulators[0] = benchmarker.createRte(conn, statMgr,
ElasqlBenchParameters.RTE_SLEEP_TIME); // Reuse the connection
for (int i = 1; i < emulators.length; i++)
emulators[i] = benchmarker.createRte(getConnection(), statMgr);
emulators[i] = benchmarker.createRte(getConnection(), statMgr,
ElasqlBenchParameters.RTE_SLEEP_TIME);

if (logger.isLoggable(Level.INFO))
logger.info("waiting for connections...");
Expand All @@ -100,12 +101,12 @@ public void benchmark() {
emulators[i].start();

// Waits for the warming up finishes
Thread.sleep(BenchmarkerParameters.WARM_UP_INTERVAL);
Thread.sleep(ElasqlBenchParameters.WARM_UP_INTERVAL);

if (logger.isLoggable(Level.INFO))
logger.info("warm up period finished.");

if (BenchmarkerParameters.PROFILING_ON_SERVER && nodeId == 0) {
if (ElasqlBenchParameters.PROFILING_ON_SERVER && nodeId == 0) {
if (logger.isLoggable(Level.INFO))
logger.info("starting the profiler on the server-side");

Expand All @@ -120,7 +121,7 @@ public void benchmark() {
emulators[i].startRecordStatistic();

// waiting
Thread.sleep(BenchmarkerParameters.BENCHMARK_INTERVAL);
Thread.sleep(ElasqlBenchParameters.BENCHMARK_INTERVAL);

if (logger.isLoggable(Level.INFO))
logger.info("benchmark preiod finished. Stoping RTEs...");
Expand All @@ -129,7 +130,7 @@ public void benchmark() {
for (int i = 0; i < emulators.length; i++)
emulators[i].stopBenchmark();

if (BenchmarkerParameters.PROFILING_ON_SERVER && nodeId == 0) {
if (ElasqlBenchParameters.PROFILING_ON_SERVER && nodeId == 0) {
if (logger.isLoggable(Level.INFO))
logger.info("stoping the profiler on the server-side");

Expand Down Expand Up @@ -166,18 +167,11 @@ public void onReceivedDirectMessage(Object message) {
}

private SutDriver newDriver(int nodeId) {
// Create a driver for connection
switch (BenchmarkerParameters.CONNECTION_MODE) {
case JDBC:
throw new UnsupportedOperationException("ElaSQL does not support JDBC");
case SP:
return new ElasqlBenchSpDriver(nodeId, this);
}
return null;
return new ElasqlBenchSpDriver(nodeId, this);
}

private Benchmark newBenchmarker(int nodeId) {
switch (BenchmarkerParameters.BENCH_TYPE) {
switch (ElasqlBenchParameters.BENCH_TYPE) {
case MICRO:
return new ElasqlMicroBenchmark();
case TPCC:
Expand All @@ -187,7 +181,7 @@ private Benchmark newBenchmarker(int nodeId) {
case YCSB:
return new ElasqlYcsbBenchmark(nodeId);
case RECON:
return new ElasqlReconBenchmark();
return new ReconBenchmark();
}
return null;
}
Expand All @@ -196,7 +190,12 @@ private StatisticMgr newStatisticMgr(Benchmark benchmarker, int nodeId) {
Set<BenchTransactionType> txnTypes = benchmarker.getBenchmarkingTxTypes();
String reportPostfix = benchmarker.getBenchmarkName();
reportPostfix += String.format("-%d", nodeId);
return new StatisticMgr(txnTypes, reportPostfix);
return new StatisticMgr(
txnTypes,
ElasqlBenchParameters.REPORT_OUTPUT_DIRECTORY,
reportPostfix,
ElasqlBenchParameters.REPORT_TIMELINE_GRANULARITY
);
}

private SutConnection getConnection() throws SQLException {
Expand Down
91 changes: 91 additions & 0 deletions src/main/java/org/elasql/bench/ElasqlBenchParameters.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
package org.elasql.bench;

import java.io.File;
import java.util.logging.Level;
import java.util.logging.Logger;

import org.elasql.bench.util.ElasqlBenchProperties;

public class ElasqlBenchParameters {
private static Logger logger = Logger.getLogger(ElasqlBenchParameters.class
.getName());

public static final long WARM_UP_INTERVAL;
public static final long BENCHMARK_INTERVAL;
public static final int NUM_RTES;
public static final long RTE_SLEEP_TIME;

// Micro = 1, TPC-C = 2, TPC-E = 3, YCSB = 4, RECON = 5
public static enum BenchType { MICRO, TPCC, TPCE, YCSB, RECON };
public static final BenchType BENCH_TYPE;

public static final boolean PROFILING_ON_SERVER;

public static final File REPORT_OUTPUT_DIRECTORY;
public static final int REPORT_TIMELINE_GRANULARITY;

public static final boolean SHOW_TXN_RESPONSE_ON_CONSOLE;

static {
WARM_UP_INTERVAL = ElasqlBenchProperties.getLoader().getPropertyAsLong(
ElasqlBenchParameters.class.getName() + ".WARM_UP_INTERVAL", 60000);

BENCHMARK_INTERVAL = ElasqlBenchProperties.getLoader().getPropertyAsLong(
ElasqlBenchParameters.class.getName() + ".BENCHMARK_INTERVAL",
60000);

NUM_RTES = ElasqlBenchProperties.getLoader().getPropertyAsInteger(
ElasqlBenchParameters.class.getName() + ".NUM_RTES", 1);

RTE_SLEEP_TIME = ElasqlBenchProperties.getLoader().getPropertyAsLong(
ElasqlBenchParameters.class.getName() + ".RTE_SLEEP_TIME", 0);

int benchType = ElasqlBenchProperties.getLoader().getPropertyAsInteger(
ElasqlBenchParameters.class.getName() + ".BENCH_TYPE", 1);
switch (benchType) {
case 1:
BENCH_TYPE = BenchType.MICRO;
break;
case 2:
BENCH_TYPE = BenchType.TPCC;
break;
case 3:
BENCH_TYPE = BenchType.TPCE;
break;
case 4:
BENCH_TYPE = BenchType.YCSB;
break;
case 5:
BENCH_TYPE = BenchType.RECON;
break;
default:
throw new IllegalArgumentException("The connection mode should be 1 (Micro), 2 (TPC-C), or 3 (TPC-E)");
}

if (logger.isLoggable(Level.INFO))
logger.info("Using " + BENCH_TYPE + " benchmarks");

PROFILING_ON_SERVER = ElasqlBenchProperties.getLoader().getPropertyAsBoolean(
ElasqlBenchParameters.class.getName() + ".PROFILING_ON_SERVER", false);

// Report Output Directory
String outputDirPath = ElasqlBenchProperties.getLoader()
.getPropertyAsString(ElasqlBenchParameters.class.getName() + ".REPORT_OUTPUT_DIRECTORY", null);

if (outputDirPath == null) {
REPORT_OUTPUT_DIRECTORY = new File(System.getProperty("user.home"), "benchmark_results");
} else {
REPORT_OUTPUT_DIRECTORY = new File(outputDirPath);
}

// Create the directory if that doesn't exist
if (!REPORT_OUTPUT_DIRECTORY.exists())
REPORT_OUTPUT_DIRECTORY.mkdir();

REPORT_TIMELINE_GRANULARITY = ElasqlBenchProperties.getLoader().getPropertyAsInteger(
ElasqlBenchParameters.class.getName() + ".REPORT_TIMELINE_GRANULARITY", 3000);

SHOW_TXN_RESPONSE_ON_CONSOLE = ElasqlBenchProperties.getLoader().getPropertyAsBoolean(
ElasqlBenchParameters.class.getName() + ".SHOW_TXN_RESPONSE_ON_CONSOLE", false);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,9 @@
public class ElasqlMicroBenchmark extends MicroBenchmark {

@Override
public RemoteTerminalEmulator<MicrobenchTransactionType> createRte(SutConnection conn, StatisticMgr statMgr) {
public RemoteTerminalEmulator<MicrobenchTransactionType> createRte(SutConnection conn, StatisticMgr statMgr,
long rteSleepTime) {
// NOTE: We use a customized version of MicroRte here
return new ElasqlMicrobenchRte(conn, statMgr);
return new ElasqlMicrobenchRte(conn, statMgr, rteSleepTime);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,9 @@ public class ElasqlMicrobenchRte extends RemoteTerminalEmulator<MicrobenchTransa

private MicrobenchmarkTxExecutor executor;

public ElasqlMicrobenchRte(SutConnection conn, StatisticMgr statMgr) {
super(conn, statMgr);
public ElasqlMicrobenchRte(SutConnection conn, StatisticMgr statMgr,
long sleepTime) {
super(conn, statMgr, sleepTime);
executor = new MicrobenchmarkTxExecutor(new ElasqlMicrobenchParamGen());
}

Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
/*******************************************************************************
* Copyright 2016, 2018 elasql.org contributors
*
* Licensed 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.elasql.bench.benchmarks.recon;

import java.sql.SQLException;
import java.util.HashSet;
import java.util.Set;

import org.vanilladb.bench.BenchTransactionType;
import org.vanilladb.bench.Benchmark;
import org.vanilladb.bench.StatisticMgr;
import org.vanilladb.bench.remote.SutConnection;
import org.vanilladb.bench.remote.SutResultSet;
import org.vanilladb.bench.rte.RemoteTerminalEmulator;

public class ReconBenchmark extends Benchmark {

@Override
public Set<BenchTransactionType> getBenchmarkingTxTypes() {
Set<BenchTransactionType> txTypes = new HashSet<BenchTransactionType>();
for (ReconbenchTransactionType txType : ReconbenchTransactionType.values()) {
if (txType.isBenchmarkingProcedure())
txTypes.add(txType);
}
return txTypes;
}

@Override
public void executeLoadingProcedure(SutConnection conn) throws SQLException {
conn.callStoredProc(ReconbenchTransactionType.TESTBED_LOADER.getProcedureId(), new Object[] {});
}

@Override
public RemoteTerminalEmulator<?> createRte(SutConnection conn, StatisticMgr statMgr, long rteSleepTime) {
// TODO Auto-generated method stub
return null;
}

@Override
public boolean executeDatabaseCheckProcedure(SutConnection conn) throws SQLException {
SutResultSet result = null;
ReconbenchTransactionType txnType = ReconbenchTransactionType.CHECK_DATABASE;
result = conn.callStoredProc(txnType.getProcedureId(), new Object[] {});
return result.isCommitted();
}

@Override
public String getBenchmarkName() {
return "reconbench";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@

import org.elasql.bench.util.ElasqlBenchProperties;

public class ElasqlReconbenchConstants {
public class ReconbenchConstants {

public static final int NUM_ITEMS_PER_NODE;

static {
NUM_ITEMS_PER_NODE = ElasqlBenchProperties.getLoader().getPropertyAsInteger(
ElasqlReconbenchConstants.class.getName() + ".NUM_ITEMS_PER_NODE", 100000);
ReconbenchConstants.class.getName() + ".NUM_ITEMS_PER_NODE", 100000);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package org.elasql.bench.benchmarks.recon;

import org.vanilladb.bench.BenchTransactionType;

public enum ReconbenchTransactionType implements BenchTransactionType {
// Loading procedures
TESTBED_LOADER(false),

// Database checking procedures
CHECK_DATABASE(false),

// Benchmarking procedures
RECON(true), EXECUTE(true), UPDATE(true);

public static ReconbenchTransactionType fromProcedureId(int pid) {
return ReconbenchTransactionType.values()[pid];
}

private boolean isBenchProc;

ReconbenchTransactionType(boolean isBenchProc) {
this.isBenchProc = isBenchProc;
}

@Override
public int getProcedureId() {
return this.ordinal();
}

@Override
public boolean isBenchmarkingProcedure() {
return isBenchProc;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
*******************************************************************************/
package org.elasql.bench.benchmarks.recon.rte;

import org.vanilladb.bench.benchmarks.recon.ReconbenchTransactionType;
import org.elasql.bench.benchmarks.recon.ReconbenchTransactionType;

public class ExecuteParamGen extends ElasqlReconbenchParamGen {
public class ExecuteParamGen extends ReconbenchParamGen {

@Override
public ReconbenchTransactionType getTxnType() {
Expand Down
Loading