Exemple #1
0
void TxnManager::commit_stats() {
    uint64_t commit_time = get_sys_clock();
    uint64_t timespan_short = commit_time - txn_stats.restart_starttime;
    uint64_t timespan_long  = commit_time - txn_stats.starttime;
    INC_STATS(get_thd_id(),total_txn_commit_cnt,1);

    if(!IS_LOCAL(get_txn_id()) && CC_ALG != CALVIN) {
      INC_STATS(get_thd_id(),remote_txn_commit_cnt,1);
      txn_stats.commit_stats(get_thd_id(),get_txn_id(),get_batch_id(), timespan_long, timespan_short);
      return;
    }


    INC_STATS(get_thd_id(),txn_cnt,1);
    INC_STATS(get_thd_id(),local_txn_commit_cnt,1);
    INC_STATS(get_thd_id(), txn_run_time, timespan_long);
    if(query->partitions_touched.size() > 1) {
      INC_STATS(get_thd_id(),multi_part_txn_cnt,1);
      INC_STATS(get_thd_id(),multi_part_txn_run_time,timespan_long);
    } else {
      INC_STATS(get_thd_id(),single_part_txn_cnt,1);
      INC_STATS(get_thd_id(),single_part_txn_run_time,timespan_long);
    }
    /*if(cflt) {
      INC_STATS(get_thd_id(),cflt_cnt_txn,1);
    }*/
    txn_stats.commit_stats(get_thd_id(),get_txn_id(),get_batch_id(),timespan_long, timespan_short);
  #if CC_ALG == CALVIN
    return;
  #endif

    INC_STATS_ARR(get_thd_id(),start_abort_commit_latency, timespan_short);
    INC_STATS_ARR(get_thd_id(),last_start_commit_latency, timespan_short);
    INC_STATS_ARR(get_thd_id(),first_start_commit_latency, timespan_long);

    assert(query->partitions_touched.size() > 0);
    INC_STATS(get_thd_id(),parts_touched,query->partitions_touched.size());
    INC_STATS(get_thd_id(),part_cnt[query->partitions_touched.size()-1],1);
    for(uint64_t i = 0 ; i < query->partitions_touched.size(); i++) {
        INC_STATS(get_thd_id(),part_acc[query->partitions_touched[i]],1);
    }
}
Exemple #2
0
//---------------------------------------------------------//
void
BatchCollector::add_contract(CAbstractContract* contract){

	long batch_id = get_batch_id(contract);

	CalculationBatch* batch = find_batch(batch_id);
	if (!batch){
		batch = add_calculation_batch(batch_id);
	};

	batch->add_item(contract);
};
Exemple #3
0
RC
TxnManager::send_remote_reads() {
  assert(CC_ALG == CALVIN);
#if !YCSB_ABORT_MODE && WORKLOAD == YCSB
  return RCOK;
#endif
  assert(query->active_nodes.size() == g_node_cnt);
  for(uint64_t i = 0; i < query->active_nodes.size(); i++) {
    if(i == g_node_id)
      continue;
    if(query->active_nodes[i] == 1) {
      DEBUG("(%ld,%ld) send_remote_read to %ld\n",get_txn_id(),get_batch_id(),i);
      msg_queue.enqueue(get_thd_id(),Message::create_message(this,RFWD),i);
    }
  }
  return RCOK;

}
Exemple #4
0
RC YCSBTxnManager::acquire_locks() {
  uint64_t starttime = get_sys_clock();
  assert(CC_ALG == CALVIN);
  YCSBQuery* ycsb_query = (YCSBQuery*) query;
  locking_done = false;
  RC rc = RCOK;
  incr_lr();
  assert(ycsb_query->requests.size() == g_req_per_query);
  assert(phase == CALVIN_RW_ANALYSIS);
	for (uint32_t rid = 0; rid < ycsb_query->requests.size(); rid ++) {
		ycsb_request * req = ycsb_query->requests[rid];
		uint64_t part_id = _wl->key_to_part( req->key );
    DEBUG("LK Acquire (%ld,%ld) %d,%ld -> %ld\n",get_txn_id(),get_batch_id(),req->acctype,req->key,GET_NODE_ID(part_id));
    if(GET_NODE_ID(part_id) != g_node_id)
      continue;
		INDEX * index = _wl->the_index;
		itemid_t * item;
		item = index_read(index, req->key, part_id);
		row_t * row = ((row_t *)item->location);
		RC rc2 = get_lock(row,req->acctype);
    if(rc2 != RCOK) {
      rc = rc2;
    }
	}
  if(decr_lr() == 0) {
    if(ATOM_CAS(lock_ready,false,true))
      rc = RCOK;
  }
  txn_stats.wait_starttime = get_sys_clock();
  /*
  if(rc == WAIT && lock_ready_cnt == 0) {
    if(ATOM_CAS(lock_ready,false,true))
    //lock_ready = true;
      rc = RCOK;
  }
  */
  INC_STATS(get_thd_id(),calvin_sched_time,get_sys_clock() - starttime);
  locking_done = true;
  return rc;
}