Skip to content

Commit

Permalink
implement tpcc response time distribution statistics
Browse files Browse the repository at this point in the history
  • Loading branch information
t-horikawa committed Oct 9, 2024
1 parent 379bd39 commit e29d77a
Show file tree
Hide file tree
Showing 8 changed files with 170 additions and 98 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public void run() {
wId = (int) delivery.warehouseId();
if (!doingDelivery.getAndSet(wId - 1, true)) {
delivery.transaction(stop);
profile.time.delivery += (System.nanoTime() - transactionStart);
profile.addTimeDelivery(System.nanoTime() - transactionStart);
doingDelivery.set(wId - 1, false);
pendingDelivery--;
if (pendingDelivery > 0) {
Expand All @@ -81,15 +81,15 @@ public void run() {
if (transactionType <= Percent.KXCT_NEWORDER_PERCENT) {
newOrder.setParams();
newOrder.transaction(stop);
profile.time.newOrder += (System.nanoTime() - transactionStart);
profile.addTimeNewOrder(System.nanoTime() - transactionStart);
} else if (transactionType <= Percent.KXCT_PAYMENT_PERCENT) {
payment.setParams();
payment.transaction(stop);
profile.time.payment += (System.nanoTime() - transactionStart);
profile.addTimePayment(System.nanoTime() - transactionStart);
} else if (transactionType <= Percent.KXCT_ORDERSTATUS_PERCENT) {
orderStatus.setParams();
orderStatus.transaction(stop);
profile.time.orderStatus += (System.nanoTime() - transactionStart);
profile.addTimeOrderStatus(System.nanoTime() - transactionStart);
} else if (transactionType <= Percent.KXCT_DELIEVERY_PERCENT) {
if (pendingDelivery > 0) {
pendingDelivery++;
Expand All @@ -99,15 +99,15 @@ public void run() {
wId = (int) delivery.warehouseId();
if (!doingDelivery.getAndSet(wId - 1, true)) {
delivery.transaction(stop);
profile.time.delivery += (System.nanoTime() - transactionStart);
profile.addTimeDelivery(System.nanoTime() - transactionStart);
doingDelivery.set(wId - 1, false);
} else {
pendingDelivery++;
}
} else {
stockLevel.setParams();
stockLevel.transaction(stop);
profile.time.stockLevel += (System.nanoTime() - transactionStart);
profile.addTimeStockLevel(System.nanoTime() - transactionStart);
}
}
profile.elapsed = System.currentTimeMillis() - start;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ void rollback(Transaction transaction) throws IOException, ServerException, Inte

@SuppressWarnings("checkstyle:methodlength")
public void transaction(AtomicBoolean stop) throws IOException, ServerException, InterruptedException {
while (!stop.get()) {
while (!stop.get()) { // placed for transaction reexecution due to failure. If the transaction ends normally, it returns.
try (var transaction = sqlClient.createTransaction().get();) {
profile.invocation.delivery++;
long dId;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

public final class Main {
private static String url = System.getProperty("tsurugi.dbname");
private static String printDistribution = System.getProperty("printResponseTimeDistribution");

static long warehouses() throws IOException, ServerException, InterruptedException, TimeoutException {
try (
Expand Down Expand Up @@ -82,7 +83,7 @@ public static void main(String[] args) {
AtomicBoolean stop = new AtomicBoolean();

for (int i = 0; i < threads; i++) {
var profile = new Profile();
var profile = new Profile(printDistribution != null ? (printDistribution == "true") : true); // default true (temporary)
profile.warehouses = warehouses;
profile.threads = threads;
profile.index = i;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ void rollback(Transaction transaction) throws IOException, ServerException, Inte

@SuppressWarnings("checkstyle:methodlength")
public void transaction(AtomicBoolean stop) throws IOException, ServerException, InterruptedException {
while (!stop.get()) {
while (!stop.get()) { // placed for transaction reexecution due to failure. If the transaction ends normally, it returns.
try (var transaction = sqlClient.createTransaction().get();) {
profile.invocation.newOrder++;
total = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ void rollback(Transaction transaction) throws IOException, ServerException, Inte

@SuppressWarnings("checkstyle:methodlength")
public void transaction(AtomicBoolean stop) throws IOException, ServerException, InterruptedException {
while (!stop.get()) {
while (!stop.get()) { // placed for transaction reexecution due to failure. If the transaction ends normally, it returns.
try (var transaction = sqlClient.createTransaction().get();) {
profile.invocation.orderStatus++;
if (!paramsByName) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ void rollback(Transaction transaction) throws IOException, ServerException, Inte

@SuppressWarnings("checkstyle:methodlength")
public void transaction(AtomicBoolean stop) throws IOException, ServerException, InterruptedException {
while (!stop.get()) {
while (!stop.get()) { // placed for transaction reexecution due to failure. If the transaction ends normally, it returns.
try (var transaction = sqlClient.createTransaction().get();) {
profile.invocation.payment++;

Expand Down
Loading

0 comments on commit e29d77a

Please sign in to comment.