void ParseArguments(int argc, char* argv[], configuration& state) {
  // Default Values
  state.logging_type = LOGGING_TYPE_DRAM_NVM;

  state.log_file_dir = TMP_DIR;
  state.data_file_size = 512;

  state.experiment_type = EXPERIMENT_TYPE_INVALID;
  state.wait_timeout = 200;

  // Default Values
  ycsb::state.scale_factor = 1;
  ycsb::state.transaction_count = 10000;
  ycsb::state.column_count = 10;
  ycsb::state.update_ratio = 0.5;
  ycsb::state.backend_count = 1;

  // Parse args
  while (1) {
    int idx = 0;
    int c = getopt_long(argc, argv, "ahl:f:e:w:k:t:c:u:b:", opts, &idx);

    if (c == -1) break;

    switch (c) {
      case 'l':
        state.logging_type = (LoggingType)atoi(optarg);
        break;
      case 'f':
        state.data_file_size = atoi(optarg);
        break;
      case 'e':
        state.experiment_type = (ExperimentType)atoi(optarg);
        break;
      case 'w':
        state.wait_timeout = atoi(optarg);
        break;

        // YCSB
      case 'k':
        ycsb::state.scale_factor = atoi(optarg);
        break;
      case 't':
        ycsb::state.transaction_count = atoi(optarg);
        break;
      case 'c':
        ycsb::state.column_count = atoi(optarg);
        break;
      case 'u':
        ycsb::state.update_ratio = atof(optarg);
        break;
      case 'b':
        ycsb::state.backend_count = atoi(optarg);
        break;

      case 'h':
        Usage(stderr);
        break;

      default:
        exit(EXIT_FAILURE);
        break;
    }
  }

  // Print configuration
  ValidateLoggingType(state);
  ValidateDataFileSize(state);
  ValidateLogFileDir(state);
  ValidateWaitTimeout(state);
  ValidateExperiment(state);

  // Print configuration
  ycsb::ValidateScaleFactor(ycsb::state);
  ycsb::ValidateColumnCount(ycsb::state);
  ycsb::ValidateUpdateRatio(ycsb::state);
  ycsb::ValidateBackendCount(ycsb::state);
  //ycsb::ValidateTransactionCount(ycsb::state);

}
예제 #2
0
void ParseArguments(int argc, char* argv[], configuration& state) {
  // Default Values
  state.logging_type = LOGGING_TYPE_NVM_WAL;

  state.log_file_dir = TMP_DIR;
  state.data_file_size = 512;

  state.experiment_type = EXPERIMENT_TYPE_INVALID;
  state.wait_timeout = 200;

  // Default Values
  // Default Values
  ycsb::state.scale_factor = 1;
  ycsb::state.duration = 10;
  ycsb::state.snapshot_duration = 0.1;
  ycsb::state.column_count = 10;
  ycsb::state.update_ratio = 0.5;
  ycsb::state.backend_count = 2;
  ycsb::state.num_loggers = 0;
  ycsb::state.sync_commit = 0;
  ycsb::state.wait_timeout = 0;
  ycsb::state.file_size = 32;
  ycsb::state.log_buffer_size = 32768;
  ycsb::state.checkpointer = 0;
  ycsb::state.flush_freq = 0;

  // Parse args
  while (1) {
    int idx = 0;
    int c = getopt_long(argc, argv, "ahk:d:s:c:u:b:l:x:w:f:z:p:q:", opts, &idx);

    if (c == -1) break;

    switch (c) {
      case 'k':
        ycsb::state.scale_factor = atoi(optarg);
        break;
      case 'd':
        ycsb::state.duration = atof(optarg);
        break;
      case 's':
        ycsb::state.snapshot_duration = atof(optarg);
        break;
      case 'c':
        ycsb::state.column_count = atoi(optarg);
        break;
      case 'u':
        ycsb::state.update_ratio = atof(optarg);
        break;
      case 'b':
        ycsb::state.backend_count = atoi(optarg);
        break;
      case 'x':
        ycsb::state.sync_commit = atoi(optarg);
        break;
      case 'l':
        ycsb::state.num_loggers = atoi(optarg);
        break;
      case 'w':
        ycsb::state.wait_timeout = atol(optarg);
        break;
      case 'f':
        ycsb::state.file_size = atoi(optarg);
        break;
      case 'z':
        ycsb::state.log_buffer_size = atoi(optarg);
        break;
      case 'p':
        ycsb::state.checkpointer = atoi(optarg);
        break;
      case 'q':
        ycsb::state.flush_freq = atoi(optarg);
        break;
      case 'h':
        Usage(stderr);
        exit(EXIT_FAILURE);
        break;
      default:
        exit(EXIT_FAILURE);
        break;
    }
  }

  // Print configurations
  ValidateLoggingType(state);
  ValidateDataFileSize(state);
  ValidateLogFileDir(state);
  ValidateWaitTimeout(state);
  ValidateExperiment(state);

  // Print configuration
  ycsb::ValidateScaleFactor(ycsb::state);
  ycsb::ValidateColumnCount(ycsb::state);
  ycsb::ValidateUpdateRatio(ycsb::state);
  ycsb::ValidateBackendCount(ycsb::state);
  ycsb::ValidateLogging(ycsb::state);
  ycsb::ValidateDuration(ycsb::state);
  ycsb::ValidateSnapshotDuration(ycsb::state);
  //  ycsb::ValidateFlushFreq(ycsb::state);
}
void ParseArguments(int argc, char* argv[], configuration& state) {
  // Default Logger Values
  state.logging_type = LOGGING_TYPE_SSD_WAL;
  state.log_file_dir = TMP_DIR;
  state.data_file_size = 512;

  state.experiment_type = EXPERIMENT_TYPE_THROUGHPUT;
  state.wait_timeout = 200;
  state.benchmark_type = BENCHMARK_TYPE_YCSB;
  state.flush_mode = 2;
  state.nvm_latency = 0;
  state.pcommit_latency = 0;
  state.asynchronous_mode = ASYNCHRONOUS_TYPE_SYNC;
  state.checkpoint_type = CHECKPOINT_TYPE_INVALID;

  // YCSB Default Values
  ycsb::state.index = INDEX_TYPE_BWTREE;
  ycsb::state.scale_factor = 1;
  ycsb::state.duration = 10;
  ycsb::state.profile_duration = 1;
  ycsb::state.backend_count = 2;
  ycsb::state.column_count = 10;
  ycsb::state.operation_count = 10;
  ycsb::state.update_ratio = 0.5;
  ycsb::state.zipf_theta = 0.0;
  ycsb::state.exp_backoff = false;
  ycsb::state.string_mode = false;
  ycsb::state.gc_mode = false;
  ycsb::state.gc_backend_count = 1;

  // TPC-C Default Values
  tpcc::state.index = INDEX_TYPE_BWTREE;
  tpcc::state.scale_factor = 1;
  tpcc::state.duration = 10;
  tpcc::state.profile_duration = 1;
  tpcc::state.backend_count = 2;
  tpcc::state.warehouse_count = 2;
  tpcc::state.exp_backoff = false;
  tpcc::state.affinity = false;
  tpcc::state.gc_mode = false;
  tpcc::state.gc_backend_count = 1;


  // Parse args
  while (1) {
    int idx = 0;
    // logger - hs:x:f:l:t:q:v:r:y:
    // ycsb   - hemgi:k:d:p:b:c:o:u:z:n:
    // tpcc   - heagi:k:d:p:b:w:n:
    int c = getopt_long(argc, argv, "hs:x:f:l:t:q:v:r:y:emgi:k:d:p:b:c:o:u:z:n:aw:j:",
                        opts, &idx);

    if (c == -1) break;

    switch (c) {
      case 's':
        state.asynchronous_mode = (AsynchronousType)atoi(optarg);
        break;
      case 'x':
        state.experiment_type = (ExperimentType)atoi(optarg);
        break;
      case 'f':
        state.data_file_size = atoi(optarg);
        break;
      case 'j':
        state.log_file_dir = optarg;
        break;
      case 'l':
        state.logging_type = (LoggingType)atoi(optarg);
        break;
      case 't':
        state.nvm_latency = atoi(optarg);
        break;
      case 'q':
        state.pcommit_latency = atoi(optarg);
        break;
      case 'v':
        state.flush_mode = atoi(optarg);
        break;
      case 'r':
        state.wait_timeout = atoi(optarg);
        break;
      case 'y':
        state.benchmark_type = (BenchmarkType)atoi(optarg);
        break;

      case 'i': {
        char *index = optarg;
        if (strcmp(index, "btree") == 0) {
          ycsb::state.index = INDEX_TYPE_BWTREE;
          tpcc::state.index = INDEX_TYPE_BWTREE;
        } else if (strcmp(index, "bwtree") == 0) {
          ycsb::state.index = INDEX_TYPE_BWTREE;
          tpcc::state.index = INDEX_TYPE_BWTREE;
        } else {
          LOG_ERROR("Unknown index: %s", index);
          exit(EXIT_FAILURE);
        }
        break;
      }
      case 'k':
        ycsb::state.scale_factor = atoi(optarg);
        tpcc::state.scale_factor = atof(optarg);
        break;
      case 'd':
        ycsb::state.duration = atof(optarg);
        tpcc::state.duration = atof(optarg);
        break;
      case 'p':
        ycsb::state.profile_duration = atof(optarg);
        tpcc::state.profile_duration = atof(optarg);
        break;
      case 'b':
        ycsb::state.backend_count = atoi(optarg);
        tpcc::state.backend_count = atoi(optarg);
        break;
      case 'c':
        ycsb::state.column_count = atoi(optarg);
        break;
      case 'o':
        ycsb::state.operation_count = atoi(optarg);
        break;
      case 'u':
        ycsb::state.update_ratio = atof(optarg);
        break;
      case 'z':
        ycsb::state.zipf_theta = atof(optarg);
        break;
      case 'e':
        ycsb::state.exp_backoff = true;
        tpcc::state.exp_backoff = true;
        break;
      case 'm':
        ycsb::state.string_mode = true;
        break;
      case 'g':
        ycsb::state.gc_mode = true;
        tpcc::state.gc_mode = true;
        break;
      case 'n':
        ycsb::state.gc_backend_count = atof(optarg);
        tpcc::state.gc_backend_count = atof(optarg);
        break;
      case 'w':
        tpcc::state.warehouse_count = atoi(optarg);
        break;
      case 'a':
        tpcc::state.affinity = true;
        break;

      case 'h':
        Usage(stderr);
        ycsb::Usage(stderr);
        tpcc::Usage(stderr);
        exit(EXIT_FAILURE);
        break;

      default:
        fprintf(stderr, "\nUnknown option: -%c-\n", c);
        Usage(stderr);
        ycsb::Usage(stderr);
        tpcc::Usage(stderr);
        exit(EXIT_FAILURE);
        break;
    }
  }

  if (state.checkpoint_type == CHECKPOINT_TYPE_NORMAL &&
      (state.logging_type == LOGGING_TYPE_NVM_WAL ||
       state.logging_type == LOGGING_TYPE_SSD_WAL ||
       state.logging_type == LOGGING_TYPE_HDD_WAL)) {
    peloton_checkpoint_mode = CHECKPOINT_TYPE_NORMAL;
  }

  // Print Logger configuration
  ValidateLoggingType(state);
  ValidateExperimentType(state);
  ValidateAsynchronousMode(state);
  ValidateBenchmarkType(state);
  ValidateDataFileSize(state);
  ValidateLogFileDir(state);
  ValidateWaitTimeout(state);
  ValidateFlushMode(state);
  ValidateNVMLatency(state);
  ValidatePCOMMITLatency(state);

  // Print YCSB configuration
  if (state.benchmark_type == BENCHMARK_TYPE_YCSB) {
    ycsb::ValidateIndex(ycsb::state);
    ycsb::ValidateScaleFactor(ycsb::state);
    ycsb::ValidateDuration(ycsb::state);
    ycsb::ValidateProfileDuration(ycsb::state);
    ycsb::ValidateBackendCount(ycsb::state);
    ycsb::ValidateColumnCount(ycsb::state);
    ycsb::ValidateOperationCount(ycsb::state);
    ycsb::ValidateUpdateRatio(ycsb::state);
    ycsb::ValidateZipfTheta(ycsb::state);
    ycsb::ValidateGCBackendCount(ycsb::state);
  }
  // Print TPCC configuration
  else if (state.benchmark_type == BENCHMARK_TYPE_TPCC) {
    tpcc::ValidateIndex(tpcc::state);
    tpcc::ValidateScaleFactor(tpcc::state);
    tpcc::ValidateDuration(tpcc::state);
    tpcc::ValidateProfileDuration(tpcc::state);
    tpcc::ValidateBackendCount(tpcc::state);
    tpcc::ValidateWarehouseCount(tpcc::state);
    tpcc::ValidateGCBackendCount(tpcc::state);

    // Static TPCC parameters
    tpcc::state.item_count = 100000 * tpcc::state.scale_factor;
    tpcc::state.districts_per_warehouse = 10;
    tpcc::state.customers_per_district = 3000 * tpcc::state.scale_factor;
    tpcc::state.new_orders_per_district = 900 * tpcc::state.scale_factor;
  }
}