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); } }
RC InputThread::client_recv_loop() { int rsp_cnts[g_servers_per_client]; memset(rsp_cnts, 0, g_servers_per_client * sizeof(int)); run_starttime = get_sys_clock(); uint64_t return_node_offset; uint64_t inf; std::vector<Message*> * msgs; while (!simulation->is_done()) { heartbeat(); uint64_t starttime = get_sys_clock(); msgs = tport_man.recv_msg(get_thd_id()); INC_STATS(_thd_id,mtx[28], get_sys_clock() - starttime); starttime = get_sys_clock(); //while((m_query = work_queue.get_next_query(get_thd_id())) != NULL) { //Message * msg = work_queue.dequeue(); if(msgs == NULL) continue; while(!msgs->empty()) { Message * msg = msgs->front(); assert(msg->rtype == CL_RSP); return_node_offset = msg->return_node_id - g_server_start_node; assert(return_node_offset < g_servers_per_client); rsp_cnts[return_node_offset]++; INC_STATS(get_thd_id(),txn_cnt,1); uint64_t timespan = get_sys_clock() - ((ClientResponseMessage*)msg)->client_startts; INC_STATS(get_thd_id(),txn_run_time, timespan); if (warmup_done) { INC_STATS_ARR(get_thd_id(),client_client_latency, timespan); } //INC_STATS_ARR(get_thd_id(),all_lat,timespan); inf = client_man.dec_inflight(return_node_offset); DEBUG("Recv %ld from %ld, %ld -- %f\n",((ClientResponseMessage*)msg)->txn_id,msg->return_node_id,inf,float(timespan)/BILLION); assert(inf >=0); // TODO: delete message msgs->erase(msgs->begin()); } delete msgs; INC_STATS(_thd_id,mtx[29], get_sys_clock() - starttime); } printf("FINISH %ld:%ld\n",_node_id,_thd_id); fflush(stdout); return FINISH; }
RC TxnManager::abort() { if(aborted) return Abort; DEBUG("Abort %ld\n",get_txn_id()); txn->rc = Abort; INC_STATS(get_thd_id(),total_txn_abort_cnt,1); txn_stats.abort_cnt++; if(IS_LOCAL(get_txn_id())) { INC_STATS(get_thd_id(), local_txn_abort_cnt, 1); } else { INC_STATS(get_thd_id(), remote_txn_abort_cnt, 1); txn_stats.abort_stats(get_thd_id()); } aborted = true; release_locks(Abort); #if CC_ALG == MAAT //assert(time_table.get_state(get_txn_id()) == MAAT_ABORTED); time_table.release(get_thd_id(),get_txn_id()); #endif uint64_t timespan = get_sys_clock() - txn_stats.restart_starttime; if (IS_LOCAL(get_txn_id()) && warmup_done) { INC_STATS_ARR(get_thd_id(),start_abort_commit_latency, timespan); } /* // latency from most recent start or restart of transaction PRINT_LATENCY("lat_s %ld %ld 0 %f %f %f %f %f %f 0.0\n" , get_txn_id() , txn_stats.work_queue_cnt , (double) timespan / BILLION , (double) txn_stats.work_queue_time / BILLION , (double) txn_stats.msg_queue_time / BILLION , (double) txn_stats.cc_block_time / BILLION , (double) txn_stats.cc_time / BILLION , (double) txn_stats.process_time / BILLION ); */ //commit_stats(); return Abort; }