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

Add Egress benchmark #217

Open
wants to merge 6 commits into
base: 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
2 changes: 1 addition & 1 deletion .github/workflows/maven.yml
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
benchmark: [ 'auctionmark', 'epinions', 'hyadapt', 'noop', 'otmetrics', 'resourcestresser', 'seats', 'sibench', 'smallbank', 'tatp', 'tpcc', 'tpch', 'twitter', 'voter', 'wikipedia', 'ycsb' ]
benchmark: [ 'auctionmark', 'egress', 'epinions', 'hyadapt', 'noop', 'otmetrics', 'resourcestresser', 'seats', 'sibench', 'smallbank', 'tatp', 'tpcc', 'tpch', 'twitter', 'voter', 'wikipedia', 'ycsb' ]
services:
postgres: # https://hub.docker.com/_/postgres
image: postgres:latest
Expand Down
16 changes: 16 additions & 0 deletions .run/egress - postgres.run.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="egress - postgres" type="Application" factoryName="Application">
<option name="MAIN_CLASS_NAME" value="com.oltpbenchmark.DBWorkload" />
<module name="benchbase" />
<option name="PROGRAM_PARAMETERS" value="-b egress -c config/postgres/sample_egress_config.xml --create=true --load=true --execute=true" />
<extension name="coverage">
<pattern>
<option name="PATTERN" value="com.oltpbenchmark.*" />
<option name="ENABLED" value="true" />
</pattern>
</extension>
<method v="2">
<option name="Make" enabled="true" />
</method>
</configuration>
</component>
1 change: 1 addition & 0 deletions config/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,5 @@
<plugin name="smallbank">com.oltpbenchmark.benchmarks.smallbank.SmallBankBenchmark</plugin>
<plugin name="hyadapt">com.oltpbenchmark.benchmarks.hyadapt.HYADAPTBenchmark</plugin>
<plugin name="otmetrics">com.oltpbenchmark.benchmarks.otmetrics.OTMetricsBenchmark</plugin>
<plugin name="egress">com.oltpbenchmark.benchmarks.egress.EgressBenchmark</plugin>
</plugins>
35 changes: 35 additions & 0 deletions config/postgres/sample_egress_config.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?xml version="1.0"?>
<parameters>

<!-- Connection details -->
<type>POSTGRES</type>
<driver>org.postgresql.Driver</driver>
<url>jdbc:postgresql://localhost:5432/benchbase?sslmode=disable&amp;ApplicationName=egress&amp;reWriteBatchedInserts=true</url>
<username>admin</username>
<password>password</password>
<isolation>TRANSACTION_SERIALIZABLE</isolation>
<batchsize>128</batchsize>

<!-- This parameter has no affect on this benchmark-->
<!-- There is no data to load -->
<scalefactor>1</scalefactor>
<egress_tuple_bytes>5</egress_tuple_bytes>
<egress_num_tuples>3</egress_num_tuples>

<!-- The workload -->
<terminals>1</terminals>
<works>
<work>
<time>60</time>
<rate>1000</rate>
<weights>100</weights>
</work>
</works>

<!-- Egress Procedures declaration -->
<transactiontypes>
<transactiontype>
<name>Egress</name>
</transactiontype>
</transactiontypes>
</parameters>
23 changes: 23 additions & 0 deletions src/main/java/com/oltpbenchmark/DBWorkload.java
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,23 @@ public static void main(String[] args) throws Exception {
// Nothing to do here !
}


int egress_tuple_bytes = -1;
try {
egress_tuple_bytes = xmlConfig.getInt("egress_tuple_bytes");
wrkld.setEgressTupleBytes(egress_tuple_bytes);
} catch (NoSuchElementException nse) {
// Nothing to do here !
}

int egress_num_tuples = -1;
try {
egress_num_tuples = xmlConfig.getInt("egress_num_tuples");
wrkld.setEgressNumTuples(egress_num_tuples);
} catch (NoSuchElementException nse) {
// Nothing to do here !
}

// ----------------------------------------------------------------
// CREATE BENCHMARK MODULE
// ----------------------------------------------------------------
Expand All @@ -176,6 +193,12 @@ public static void main(String[] args) throws Exception {
if (selectivity != -1) {
initDebug.put("Selectivity", selectivity);
}
if (egress_tuple_bytes != -1) {
initDebug.put("Egress Tuple Bytes", egress_tuple_bytes);
}
if (egress_num_tuples != -1) {
initDebug.put("Egress Num Tuples", egress_num_tuples);
}

LOG.info("{}\n\n{}", SINGLE_LINE, StringUtil.formatMaps(initDebug));
LOG.info(SINGLE_LINE);
Expand Down
27 changes: 27 additions & 0 deletions src/main/java/com/oltpbenchmark/WorkloadConfiguration.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ public class WorkloadConfiguration {
private int randomSeed = -1;
private double scaleFactor = 1.0;
private double selectivity = -1.0;
private int egressTupleBytes = 10;
private int egressNumTuples = 10;
private int terminals;
private int loaderThreads = ThreadUtil.availableProcessors();
private XMLConfiguration xmlConfig = null;
Expand Down Expand Up @@ -152,8 +154,33 @@ public void addPhase(int id, int time, int warmup, int rate, List<Double> weight
phases.add(new Phase(benchmarkName, id, time, warmup, rate, weights, rateLimited, disabled, serial, timed, active_terminals, arrival));
}

/**
* @return egressTupleBytes length of text field for Egress benchmark.
*/
public int getEgressTupleBytes() {
return egressTupleBytes;
}

/**
* @param egressTupleBytes length of text field for Egress benchmark.
*/
public void setEgressTupleBytes(int egressTupleBytes) {
this.egressTupleBytes = egressTupleBytes;
}

/**
* @return egressNumTuples Number of tuples returned for Egress benchmark.
*/
public int getEgressNumTuples() {
return egressNumTuples;
}

/**
* @param egressNumTuples Number of tuples returned for Egress benchmark.
*/
public void setEgressNumTuples(int egressNumTuples) {
this.egressNumTuples = egressNumTuples;
}

/**
* The number of loader threads that the framework is allowed to use.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
/*
* Copyright 2020 by OLTPBenchmark Project
*
* 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 com.oltpbenchmark.benchmarks.egress;

import com.oltpbenchmark.WorkloadConfiguration;
import com.oltpbenchmark.api.BenchmarkModule;
import com.oltpbenchmark.api.Loader;
import com.oltpbenchmark.api.Worker;
import com.oltpbenchmark.benchmarks.egress.procedures.Egress;

import java.util.ArrayList;
import java.util.List;

/**
* The Egress Benchmark doesn't have any tables. It uses a UDF to generate tuples to return back to the client.
*
* @author mbutrovich
*/
public class EgressBenchmark extends BenchmarkModule {

public EgressBenchmark(WorkloadConfiguration workConf) {
super(workConf);
}

@Override
protected List<Worker<? extends BenchmarkModule>> makeWorkersImpl() {
List<Worker<? extends BenchmarkModule>> workers = new ArrayList<>();
for (int i = 0; i < workConf.getTerminals(); ++i) {
workers.add(new EgressWorker(this, i));
}
return workers;
}

@Override
protected Loader<EgressBenchmark> makeLoaderImpl() {
return new EgressLoader(this);
}

@Override
protected Package getProcedurePackageImpl() {
return Egress.class.getPackage();
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/*
* Copyright 2020 by OLTPBenchmark Project
*
* 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 com.oltpbenchmark.benchmarks.egress;

import com.oltpbenchmark.api.Loader;
import com.oltpbenchmark.api.LoaderThread;

import java.util.ArrayList;
import java.util.List;

/**
* This doesn't load any data!
*
* @author mbutrovich
*/
public class EgressLoader extends Loader<EgressBenchmark> {
public EgressLoader(EgressBenchmark benchmark) {
super(benchmark);
}

@Override
public List<LoaderThread> createLoaderThreads() {
return new ArrayList<>();
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
/*
* Copyright 2020 by OLTPBenchmark Project
*
* 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 com.oltpbenchmark.benchmarks.egress;

import com.oltpbenchmark.api.Procedure.UserAbortException;
import com.oltpbenchmark.api.TransactionType;
import com.oltpbenchmark.api.Worker;
import com.oltpbenchmark.benchmarks.egress.procedures.Egress;
import com.oltpbenchmark.types.TransactionStatus;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.sql.Connection;

/**
* @author mbutrovich
*/
public class EgressWorker extends Worker<EgressBenchmark> {
private static final Logger LOG = LoggerFactory.getLogger(EgressWorker.class);

private final Egress procEgress;
private final int tupleBytes;
private final int numTuples;

public EgressWorker(EgressBenchmark benchmarkModule, int id) {
super(benchmarkModule, id);
this.procEgress = this.getProcedure(Egress.class);
this.tupleBytes = this.getWorkloadConfiguration().getEgressTupleBytes();
this.numTuples = this.getWorkloadConfiguration().getEgressNumTuples();
}

@Override
protected TransactionStatus executeWork(Connection conn, TransactionType nextTrans) throws UserAbortException {

LOG.debug("Executing {}", this.procEgress);
try {
this.procEgress.run(conn, this.tupleBytes, this.numTuples);
if (LOG.isDebugEnabled()) {
LOG.debug("Successfully completed {} execution!", this.procEgress);
}
} catch (Exception ex) {
LOG.error(ex.getMessage(), ex);
}

return (TransactionStatus.SUCCESS);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
/*
* Copyright 2020 by OLTPBenchmark Project
*
* 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 com.oltpbenchmark.benchmarks.egress.procedures;

import com.oltpbenchmark.api.Procedure;
import com.oltpbenchmark.api.SQLStmt;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

/**
* The actual Egress implementation
*
* @author mbutrovich
*/
public class Egress extends Procedure {
private static final Logger LOG = LoggerFactory.getLogger(Egress.class);


// There's no generic query for this benchmark so we leave it as an empty statement. Implement a DBMS-specific DDL
// and dialect as needed.
public final SQLStmt egressStmt = new SQLStmt(";");

public void run(Connection conn, int tuple_bytes, int num_tuples) {
try (PreparedStatement stmt = this.getPreparedStatement(conn, egressStmt)) {
stmt.setInt(1, tuple_bytes);
stmt.setInt(2, num_tuples);
stmt.executeQuery();
// We don't care about the ResultSet.
} catch (SQLException ex) {
throw new RuntimeException(ex.getMessage() + ex.getCause());
}
}

}
11 changes: 11 additions & 0 deletions src/main/resources/benchmarks/egress/ddl-postgres.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
CREATE OR REPLACE FUNCTION egress(text_length int, num_rows int) RETURNS SETOF RECORD AS $$
DECLARE
rec record;
temp_string text;
BEGIN
SELECT lpad('', text_length, 'x') INTO temp_string;
FOR i IN 1..num_rows LOOP
select temp_string into rec;
return next rec;
END LOOP;
END $$ language plpgsql;
11 changes: 11 additions & 0 deletions src/main/resources/benchmarks/egress/dialect-postgres.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0"?>
<dialects>
<dialect type="POSTGRES">
<procedure name="Egress">
<statement name="egressStmt">
SELECT RPAD('',?,'x') from generate_series(1,?);
<!-- SELECT * FROM egress(?, ?) as egress_results(egress_data text);-->
</statement>
</procedure>
</dialect>
</dialects>