Exemplo n.º 1
0
 @Override
 public void callPaymentByName(
     short w_id,
     byte d_id,
     double h_amount,
     short c_w_id,
     byte c_d_id,
     byte[] c_last,
     TimestampType now)
     throws IOException {
   try {
     if ((scaleParams.warehouses > 1) || (c_last != null)) {
       m_clientCon.executeAsync(
           new VerifyBasicCallback(),
           Constants.PAYMENT_BY_NAME_W,
           w_id,
           d_id,
           h_amount,
           c_w_id,
           c_d_id,
           c_last,
           now);
       m_clientCon.executeAsync(
           new VerifyBasicCallback(
               TPCCSimulation.Transaction.PAYMENT, Constants.PAYMENT_BY_NAME_C),
           Constants.PAYMENT_BY_NAME_C,
           w_id,
           d_id,
           h_amount,
           c_w_id,
           c_d_id,
           c_last,
           now);
     } else {
       m_clientCon.executeAsync(
           new VerifyBasicCallback(TPCCSimulation.Transaction.PAYMENT, Constants.PAYMENT_BY_ID),
           Constants.PAYMENT_BY_ID,
           w_id,
           d_id,
           h_amount,
           c_w_id,
           c_d_id,
           c_last,
           now);
     }
   } catch (Exception e) {
     throw new IOException(e);
   }
 }
Exemplo n.º 2
0
 @Override
 public void callNewOrder(boolean rollback, Object... paramlist) throws IOException {
   try {
     m_clientCon.executeAsync(new NewOrderCallback(rollback), Constants.NEWORDER, paramlist);
   } catch (Exception e) {
     throw new IOException(e);
   }
 }
Exemplo n.º 3
0
 @Override
 public void callDelivery(short w_id, int carrier, TimestampType date) throws IOException {
   try {
     m_clientCon.executeAsync(new DeliveryCallback(), Constants.DELIVERY, w_id, carrier, date);
   } catch (Exception e) {
     throw new IOException(e);
   }
 }
Exemplo n.º 4
0
 @Override
 public void callStockLevel(short w_id, byte d_id, int threshold) throws IOException {
   final StockLevelCallback cb = new StockLevelCallback();
   try {
     m_clientCon.executeAsync(cb, Constants.STOCK_LEVEL, w_id, d_id, threshold);
   } catch (Exception e) {
     throw new IOException(e);
   }
 }
Exemplo n.º 5
0
 @Override
 public void callOrderStatus(String proc, Object... paramlist) throws IOException {
   try {
     m_clientCon.executeAsync(
         new VerifyBasicCallback(TPCCSimulation.Transaction.ORDER_STATUS, proc), proc, paramlist);
   } catch (Exception e) {
     throw new IOException(e);
   }
 }
Exemplo n.º 6
0
 @Override
 public void callResetWarehouse(
     long w_id, long districtsPerWarehouse, long customersPerDistrict, long newOrdersPerDistrict)
     throws IOException {
   try {
     m_clientCon.executeAsync(
         new ResetWarehouseCallback(),
         Constants.RESET_WAREHOUSE,
         w_id,
         districtsPerWarehouse,
         customersPerDistrict,
         newOrdersPerDistrict);
   } catch (Exception e) {
     throw new IOException(e);
   }
 }
Exemplo n.º 7
0
  public void run() {
    long transactions_per_second = m_helpah.longValue("ratelimit");
    long transactions_per_milli = transactions_per_second / 1000l;
    long client_feedback_interval_secs = m_helpah.longValue("displayinterval");
    long testDurationSecs = m_helpah.longValue("duration");
    long lag_latency_seconds = 0;
    long lag_latency_millis = lag_latency_seconds * 1000l;
    long thisOutstanding = 0;
    long lastOutstanding = 0;
    final String statsFile = m_helpah.stringValue("statsfile");

    long transactions_this_second = 0;
    long last_millisecond = System.currentTimeMillis();
    long this_millisecond = System.currentTimeMillis();

    setTransactionDisplayNames();

    long startTime = System.currentTimeMillis();
    long endTime = startTime + (1000l * testDurationSecs);
    long currentTime = startTime;
    long lastFeedbackTime = startTime;
    long numSPCalls = 0;
    long startRecordingLatency = startTime + lag_latency_millis;

    while (endTime > currentTime) {
      numSPCalls++;

      try {
        tpccSim.doOne();
      } catch (IOException e) {
      }

      transactions_this_second++;
      if (transactions_this_second >= transactions_per_milli) {
        this_millisecond = System.currentTimeMillis();
        while (this_millisecond <= last_millisecond) {
          this_millisecond = System.currentTimeMillis();
        }
        last_millisecond = this_millisecond;
        transactions_this_second = 0;
      }

      currentTime = System.currentTimeMillis();

      if ((!checkLatency) && (currentTime >= startRecordingLatency)) {
        // time to start recording latency information
        checkLatency = true;
      }

      if (currentTime >= (lastFeedbackTime + (client_feedback_interval_secs * 1000))) {
        final long elapsedTimeMillis2 = System.currentTimeMillis() - startTime;
        lastFeedbackTime = currentTime;

        final long runTimeMillis = endTime - startTime;

        float elapsedTimeSec2 = (System.currentTimeMillis() - startTime) / 1000F;
        if (totExecutionsLatency == 0) {
          totExecutionsLatency = 1;
        }

        double percentComplete = ((double) elapsedTimeMillis2 / (double) runTimeMillis) * 100;
        if (percentComplete > 100.0) {
          percentComplete = 100.0;
        }

        counterLock.lock();
        try {
          thisOutstanding = numSPCalls - totExecutions;

          double avgLatency = (double) totExecutionMilliseconds / (double) totExecutionsLatency;
          double tps = numSPCalls / elapsedTimeSec2;

          System.out.printf(
              "%.3f%% Complete | Allowing %,d SP calls/sec: made %,d SP calls at %,.2f SP/sec | outstanding = %d (%d) | min = %d | max = %d | avg = %.2f\n",
              percentComplete,
              (transactions_per_milli * 1000l),
              numSPCalls,
              tps,
              thisOutstanding,
              (thisOutstanding - lastOutstanding),
              minExecutionMilliseconds,
              maxExecutionMilliseconds,
              avgLatency);
          for (int i = 0; i < procNames.length; i++) {
            System.out.printf("%16s: %10d total,", procNames[i], procCounts[i].intValue());
          }
          System.out.println();

          lastOutstanding = thisOutstanding;
        } finally {
          counterLock.unlock();
        }
      }
    }

    try {
      m_clientCon.drain();
    } catch (Exception e) {
      e.printStackTrace();
      System.exit(-1);
    }

    long elapsedTimeMillis = System.currentTimeMillis() - startTime;
    float elapsedTimeSec = elapsedTimeMillis / 1000F;

    System.out.println(
        "============================== BENCHMARK RESULTS ==============================");
    System.out.printf("Time: %d ms\n", elapsedTimeMillis);
    System.out.printf("Total transactions: %d\n", numSPCalls);
    System.out.printf("Transactions per second: %.2f\n", (float) numSPCalls / elapsedTimeSec);
    for (int i = 0; i < procNames.length; i++) {
      System.out.printf(
          "%23s: %10d total %12.2f txn/s %12.2f txn/m\n",
          procNames[i],
          procCounts[i].intValue(),
          procCounts[i].floatValue() / elapsedTimeSec,
          procCounts[i].floatValue() * 60 / elapsedTimeSec);
    }
    System.out.println(
        "===============================================================================\n");

    System.out.println("\n");
    System.out.println("*************************************************************************");
    System.out.println("System Statistics");
    System.out.println("*************************************************************************");

    System.out.printf(" - Ran for %,.2f seconds\n", elapsedTimeSec);
    System.out.printf(" - Performed %,d Stored Procedure calls\n", numSPCalls);
    System.out.printf(" - At %,.2f calls per second\n", numSPCalls / elapsedTimeSec);
    System.out.printf(
        " - Average Latency = %.2f ms\n",
        ((double) totExecutionMilliseconds / (double) totExecutionsLatency));
    System.out.printf(" -   Latency   0ms -  25ms = %,d\n", latencyCounter[0]);
    System.out.printf(" -   Latency  25ms -  50ms = %,d\n", latencyCounter[1]);
    System.out.printf(" -   Latency  50ms -  75ms = %,d\n", latencyCounter[2]);
    System.out.printf(" -   Latency  75ms - 100ms = %,d\n", latencyCounter[3]);
    System.out.printf(" -   Latency 100ms - 125ms = %,d\n", latencyCounter[4]);
    System.out.printf(" -   Latency 125ms - 150ms = %,d\n", latencyCounter[5]);
    System.out.printf(" -   Latency 150ms - 175ms = %,d\n", latencyCounter[6]);
    System.out.printf(" -   Latency 175ms - 200ms = %,d\n", latencyCounter[7]);
    System.out.printf(" -   Latency 200ms+        = %,d\n", latencyCounter[8]);

    // 3. Performance statistics
    System.out.println(
        "\n\n-------------------------------------------------------------------------------------\n"
            + " System Statistics\n"
            + "-------------------------------------------------------------------------------------\n\n");
    System.out.print(m_clientCon.getStatistics(Constants.TRANS_PROCS).toString(false));

    // Dump stats to file
    try {
      m_clientCon.saveStatistics(statsFile);
    } catch (IOException e) {
      System.err.println("Unable to save statistics file: " + e.getMessage());
    }

    m_clientCon.close();
  }
Exemplo n.º 8
0
  public MyTPCC(String args[]) {
    m_helpah = new AppHelper(MyTPCC.class.getCanonicalName());
    m_helpah.add("duration", "run_duration_in_seconds", "Benchmark duration, in seconds.", 180);
    m_helpah.add("warehouses", "number_of_warehouses", "Number of warehouses", 12);
    m_helpah.add("scalefactor", "scale_factor", "Scale factor", 1.0);
    m_helpah.add("skewfactor", "skew_factor", "Skew factor", 0.0);
    m_helpah.add("loadthreads", "number_of_load_threads", "Number of load threads", 4);
    m_helpah.add("ratelimit", "rate_limit", "Rate limit to start from (tps)", 200000);
    m_helpah.add(
        "displayinterval",
        "display_interval_in_seconds",
        "Interval for performance feedback, in seconds.",
        10);
    m_helpah.add(
        "servers",
        "comma_separated_server_list",
        "List of VoltDB servers to connect to.",
        "localhost");
    m_helpah.setArguments(args);

    // default values
    int warehouses = m_helpah.intValue("warehouses");
    double scalefactor = m_helpah.doubleValue("scalefactor");
    double skewfactor = m_helpah.doubleValue("skewfactor");

    String servers = m_helpah.stringValue("servers");
    System.out.printf("Connecting to servers: %s\n", servers);
    int sleep = 1000;
    while (true) {
      try {
        m_clientCon = ClientConnectionPool.get(servers, 21212);
        break;
      } catch (Exception e) {
        System.err.printf("Connection failed - retrying in %d second(s).\n", sleep / 1000);
        try {
          Thread.sleep(sleep);
        } catch (Exception tie) {
        }
        if (sleep < 8000) sleep += sleep;
      }
    }
    System.out.println("Connected.  Starting benchmark.");

    try {
      if ((int)
              (m_clientCon
                  .execute(LoadStatus.class.getSimpleName())
                  .getResults()[0]
                  .fetchRow(0)
                  .getLong(0))
          == 0) (new MyLoader(args, m_clientCon)).run();
      else
        while ((int)
                (m_clientCon
                    .execute(LoadStatus.class.getSimpleName())
                    .getResults()[0]
                    .fetchRow(0)
                    .getLong(0))
            < warehouses) ;
    } catch (Exception e) {
      System.exit(-1);
    }

    // makeForRun requires the value cLast from the load generator in
    // order to produce a valid generator for the run. Thus the sort
    // of weird eat-your-own ctor pattern.
    RandomGenerator.NURandC base_loadC = new RandomGenerator.NURandC(0, 0, 0);
    RandomGenerator.NURandC base_runC =
        RandomGenerator.NURandC.makeForRun(new RandomGenerator.Implementation(0), base_loadC);
    RandomGenerator rng = new RandomGenerator.Implementation(0);
    rng.setC(base_runC);

    scaleParams = ScaleParameters.makeWithScaleFactor(warehouses, scalefactor);
    tpccSim = new TPCCSimulation(this, rng, new Clock.RealTime(), scaleParams, false, skewfactor);
  }