コード例 #1
0
ファイル: ycsb_workload.cpp プロジェクト: abpoms/peloton-opt
void RunBackend(oid_t thread_id) {
  auto txn_count = state.transaction_count;
  auto update_ratio = state.update_ratio;

  UniformGenerator generator;
  Timer<> timer;

  // Start timer
  timer.Reset();
  timer.Start();

  // Run these many transactions
  for (oid_t txn_itr = 0; txn_itr < txn_count; txn_itr++) {
    auto rng_val = generator.GetSample();

    if (rng_val < update_ratio) {
      RunUpdate();
    }
    else {
      RunRead();
    }

  }

  // Stop timer
  timer.Stop();

  // Set duration
  durations[thread_id] = timer.GetDuration();
}
コード例 #2
0
void RunBackend(oid_t thread_id) {
  auto update_ratio = state.update_ratio;

  UniformGenerator generator;

  oid_t &execution_count_ref = abort_counts[thread_id];
  oid_t &transaction_count_ref = commit_counts[thread_id];

  // Run these many transactions
  while (true) {
    if (is_running == false) {
      break;
    }
    auto rng_val = generator.GetSample();

    if (rng_val < update_ratio) {
      while (RunUpdate() == false) {
        execution_count_ref++;
      }
    } else {
      while (RunRead() == false) {
        execution_count_ref++;
      }
    }

    transaction_count_ref++;

  }
}
コード例 #3
0
ファイル: run.cpp プロジェクト: hpc/mvapich-cce
void RunWorkerThread()
{
    DWORD dwKey, nBytes;
    OVERLAPPED *p_Ovl;
    int error;
    MPD_Context *pContext;
    int ret_val;

    while (true)
    {
        if (GetQueuedCompletionStatus(g_hCommPort, &nBytes, &dwKey, &p_Ovl, INFINITE))
        {
            //dbg_printf("RunWorkerThread::%d bytes\n", nBytes);
            if (dwKey == EXIT_WORKER_KEY)
                ExitThread(0);
            pContext = (MPD_Context*)dwKey;
            if (nBytes)
            {
                if (nBytes == 1)
                {
                    pContext->bReadPosted = false;
                    if (!RunRead(pContext, &ret_val))
                        ErrorExit("RunRead returned FALSE", ret_val);

                    if (pContext->bDeleteMe)
                    {
                        RemoveContext(pContext);
                        pContext = NULL;
                    }
                    else
                    {
                        // post the next read
                        error = PostContextRead(pContext);
                        if (error)
                        {
                            if (error == ERROR_NETNAME_DELETED || error == ERROR_IO_PENDING || error == WSAECONNABORTED)
                                dbg_printf("RunWorkerThread:Post read for %s(%d) failed, error %d\n", ContextTypeToString(pContext), pContext->sock, error);
                            else
                                err_printf("RunWorkerThread:Post read for %s(%d) failed, error %d\n", ContextTypeToString(pContext), pContext->sock, error);
                            RemoveContext(pContext);
                            pContext = NULL;
                        }
                    }
                }
                else
                {
                    dbg_printf("RunWorkerThread: nBytes = %d, *** unexpected ***\n", nBytes);
                    error = PostContextRead(pContext);
                    if (error)
                    {
                        err_printf("RunWorkerThread:Post read for %s(%d) failed, error %d\n", ContextTypeToString(pContext), pContext->sock, error);
                        RemoveContext(pContext);
                        pContext = NULL;
                    }
                }
            }
            else
            {
                dbg_printf("RunWorkerThread::closing context %s(%d)\n", ContextTypeToString(pContext), pContext->sock);
                RemoveContext(pContext);
                pContext = NULL;
            }
        }
        else
        {
            error = GetLastError();
            if (error == ERROR_NETNAME_DELETED || error == ERROR_IO_PENDING || error == WSAECONNABORTED)
            {
                dbg_printf("RunWorkerThread: GetQueuedCompletionStatus failed, error %d\n", error);
            }
            else
            {
                err_printf("RunWorkerThread: GetQueuedCompletionStatus failed, error %d\n", error);
            }
            //return;
        }
    }
}