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

Tpcc fix #146

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 3 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
7 changes: 5 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,11 @@
<packaging>jar</packaging>

<properties>
<maven.compiler.source>1.10</maven.compiler.source>
<maven.compiler.target>1.10</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<java.version>21</java.version>
<maven.compiler.source>21</maven.compiler.source>
<maven.compiler.target>21</maven.compiler.target>
<buildDirectory>${project.basedir}/target</buildDirectory>
</properties>

<!-- *************************************** BUILDING *************************************** -->
Expand Down
5 changes: 5 additions & 0 deletions src/com/oltpbenchmark/CommandLineOptions.java
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ public class CommandLineOptions {
COMMAND_LINE_OPTS.addOption(null, "merge-json-results", true, "Merge results from various json output files");
COMMAND_LINE_OPTS.addOption(null, "dir", true, "Directory containing the csv files");
COMMAND_LINE_OPTS.addOption(null, "vv", false, "Output verbose execute results");
COMMAND_LINE_OPTS.addOption("vt", "virtual-threads", true, "Use Virtual threads");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Default value must be false.

}

public CommandLineOptions() {}
Expand Down Expand Up @@ -175,6 +176,10 @@ public Optional<Integer> getInitialDelaySeconds() {
return getIntOpt("initial-delay-secs");
}

public boolean getUseVirtualThreads() {
return isBooleanOptionSet("vt") || isBooleanOptionSet("virtual-threads");
}

public boolean getIsCreateSqlProceduresSet() {
return isBooleanOptionSet("create-sql-procedures");
}
Expand Down
7 changes: 5 additions & 2 deletions src/com/oltpbenchmark/DBWorkload.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public class DBWorkload {
private static int warmupTime = 0;
private static final Map<Integer, String> transactionTypes = new HashMap<>();
private static JsonMetricsHelper jsonMetricsHelper = new JsonMetricsHelper();

private static Boolean useVirtualThreads = false;
/**
* Returns true if asserts are enabled. This assumes that
* we're always using the default system ClassLoader
Expand Down Expand Up @@ -88,6 +88,9 @@ public static void main(String[] args) throws Exception {
transactionTypes.put(5, "StockLevel");

numWarehouses = options.getWarehouses().orElse(numWarehouses);
if(options.getUseVirtualThreads()) {
useVirtualThreads = true;
}

String configFile = options.getConfigFile().orElse("config/workload_all.xml");
ConfigFileOptions configOptions = new ConfigFileOptions(configFile);
Expand Down Expand Up @@ -482,7 +485,7 @@ private static Results runWorkload(List<BenchmarkModule> benchList, int interval
bench.getBenchmarkName().toUpperCase(), num_phases, (num_phases > 1 ? "s" : "")));
workConfs.add(bench.getWorkloadConfiguration());
}
Results r = ThreadBench.runRateLimitedBenchmark(workers, workConfs, intervalMonitor);
Results r = ThreadBench.runRateLimitedBenchmark(workers, workConfs, intervalMonitor, useVirtualThreads);
r.startTime = start;
r.endTime = end;

Expand Down
19 changes: 15 additions & 4 deletions src/com/oltpbenchmark/ThreadBench.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,14 @@ public class ThreadBench implements Thread.UncaughtExceptionHandler {
private final List<WorkloadState> workStates;
final ArrayList<TransactionLatencyRecord.Sample> samples = new ArrayList<>();
private int intervalMonitor = 0;
private boolean useVirtualThreads = false;

public ThreadBench(List<? extends Worker> workers, List<WorkloadConfiguration> workConfs) {
public ThreadBench(List<? extends Worker> workers, List<WorkloadConfiguration> workConfs, boolean useVirtualThreads) {
this.workers = workers;
this.workConfs = workConfs;
this.workerThreads = new ArrayList<>(workers.size());
this.workStates = new ArrayList<>();
this.useVirtualThreads = useVirtualThreads;
}

public static final class TimeBucketIterable implements Iterable<DistributionStatistics> {
Expand Down Expand Up @@ -164,8 +166,17 @@ public void remove() {
private void createWorkerThreads() {
for (Worker worker : workers) {
worker.initializeState();
Thread thread = new Thread(worker);
Thread thread;
if(useVirtualThreads) {
thread = Thread.ofVirtual().unstarted(worker);
LOG.info("starting a virtual thread!");
}
else{
LOG.info("starting a phyiscal thread!");
thread = new Thread(worker);
}
thread.setUncaughtExceptionHandler(this);
// LOG.info("starting a new virtual thread!");
thread.start();
this.workerThreads.add(thread);
}
Expand Down Expand Up @@ -276,8 +287,8 @@ public void run() {
}
} // CLASS

public static Results runRateLimitedBenchmark(List<Worker> workers, List<WorkloadConfiguration> workConfs, int intervalMonitoring) {
ThreadBench bench = new ThreadBench(workers, workConfs);
public static Results runRateLimitedBenchmark(List<Worker> workers, List<WorkloadConfiguration> workConfs, int intervalMonitoring, boolean useVirtualThreads) {
ThreadBench bench = new ThreadBench(workers, workConfs, useVirtualThreads);
bench.intervalMonitor = intervalMonitoring;
return bench.runRateLimitedMultiPhase();
}
Expand Down