Skip to content

Commit 641e5b4

Browse files
committed
Merge pull request Percona-Lab#1 from mdcallag/master
Adds per-transaction latencies, lets per-transaction latencies be set
2 parents efd6219 + 1592386 commit 641e5b4

File tree

2 files changed

+45
-13
lines changed

2 files changed

+45
-13
lines changed

src/driver.c

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -42,17 +42,13 @@ extern int* failure2[];
4242
extern double max_rt[];
4343
extern double total_rt[];
4444

45+
extern int rt_limit[];
46+
4547
extern long clk_tck;
4648
extern sb_percentile_t local_percentile;
4749

4850
#define MAX_RETRY 2000
4951

50-
#define RTIME_NEWORD 5
51-
#define RTIME_PAYMENT 5
52-
#define RTIME_ORDSTAT 5
53-
#define RTIME_DELIVERY 80
54-
#define RTIME_SLEV 20
55-
5652
int driver (int t_num)
5753
{
5854
int i, j;
@@ -154,7 +150,7 @@ static int do_neword (int t_num)
154150
sb_percentile_update(&local_percentile, rt);
155151
hist_inc(0, rt);
156152
if(counting_on){
157-
if( rt < RTIME_NEWORD ){
153+
if( rt < rt_limit[0]){
158154
success[0]++;
159155
success2[0][t_num]++;
160156
}else{
@@ -248,7 +244,7 @@ static int do_payment (int t_num)
248244
total_rt[1] += rt;
249245
hist_inc(1, rt);
250246
if(counting_on){
251-
if( rt < RTIME_PAYMENT ){
247+
if( rt < rt_limit[1]){
252248
success[1]++;
253249
success2[1][t_num]++;
254250
}else{
@@ -321,7 +317,7 @@ static int do_ordstat (int t_num)
321317
total_rt[2] += rt;
322318
hist_inc(2, rt);
323319
if(counting_on){
324-
if( rt < RTIME_ORDSTAT ){
320+
if( rt < rt_limit[2]){
325321
success[2]++;
326322
success2[2][t_num]++;
327323
}else{
@@ -387,7 +383,7 @@ static int do_delivery (int t_num)
387383
total_rt[3] += rt;
388384
hist_inc(3, rt );
389385
if(counting_on){
390-
if( rt < RTIME_DELIVERY ){
386+
if( rt < rt_limit[3]){
391387
success[3]++;
392388
success2[3][t_num]++;
393389
}else{
@@ -454,7 +450,7 @@ static int do_slev (int t_num)
454450
total_rt[4] += rt;
455451
hist_inc(4, rt );
456452
if(counting_on){
457-
if( rt < RTIME_SLEV ){
453+
if( rt < rt_limit[4]){
458454
success[4]++;
459455
success2[4][t_num]++;
460456
}else{

src/main.c

Lines changed: 38 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,20 @@ double cur_max_rt[5];
7979

8080
double prev_total_rt[5];
8181

82+
#define RTIME_NEWORD 5
83+
#define RTIME_PAYMENT 5
84+
#define RTIME_ORDSTAT 5
85+
#define RTIME_DELIVERY 80
86+
#define RTIME_SLEV 20
87+
88+
int rt_limit[5] = {
89+
RTIME_NEWORD,
90+
RTIME_PAYMENT,
91+
RTIME_ORDSTAT,
92+
RTIME_DELIVERY,
93+
RTIME_SLEV
94+
};
95+
8296
sb_percentile_t local_percentile;
8397

8498
int activate_transaction;
@@ -153,7 +167,7 @@ int main( int argc, char *argv[] )
153167

154168
/* Parse args */
155169

156-
while ( (c = getopt(argc, argv, "h:P:d:u:p:w:c:r:l:i:f:t:m:o:S:")) != -1) {
170+
while ( (c = getopt(argc, argv, "h:P:d:u:p:w:c:r:l:i:f:t:m:o:S:0:1:2:3:4:")) != -1) {
157171
switch (c) {
158172
case 'h':
159173
printf ("option h with value '%s'\n", optarg);
@@ -215,6 +229,26 @@ int main( int argc, char *argv[] )
215229
printf ("option S (socket) with value '%s'\n", optarg);
216230
strncpy(db_socket, optarg, DB_STRING_MAX);
217231
break;
232+
case '0':
233+
printf ("option 0 (response time limit for transaction 0) '%s'\n", optarg);
234+
rt_limit[0] = atoi(optarg);
235+
break;
236+
case '1':
237+
printf ("option 1 (response time limit for transaction 1) '%s'\n", optarg);
238+
rt_limit[1] = atoi(optarg);
239+
break;
240+
case '2':
241+
printf ("option 2 (response time limit for transaction 2) '%s'\n", optarg);
242+
rt_limit[2] = atoi(optarg);
243+
break;
244+
case '3':
245+
printf ("option 3 (response time limit for transaction 3) '%s'\n", optarg);
246+
rt_limit[3] = atoi(optarg);
247+
break;
248+
case '4':
249+
printf ("option 4 (response time limit for transaction 4) '%s'\n", optarg);
250+
rt_limit[4] = atoi(optarg);
251+
break;
218252
case '?':
219253
printf("Usage: tpcc_start -h server_host -P port -d database_name -u mysql_user -p mysql_password -w warehouses -c connections -r warmup_time -l running_time -i report_interval -f report_file -t trx_file\n");
220254
exit(0);
@@ -497,7 +531,9 @@ int main( int argc, char *argv[] )
497531

498532
printf("\n<Raw Results>\n");
499533
for ( i=0; i<5; i++ ){
500-
printf(" [%d] sc:%d lt:%d rt:%d fl:%d \n", i, success[i], late[i], retry[i], failure[i]);
534+
printf(" [%d] sc:%d lt:%d rt:%d fl:%d avg_rt: %.1f (%d)\n",
535+
i, success[i], late[i], retry[i], failure[i],
536+
total_rt[i] / (success[i] + late[i]), rt_limit[i]);
501537
}
502538
printf(" in %d sec.\n", (measure_time / PRINT_INTERVAL) * PRINT_INTERVAL);
503539

0 commit comments

Comments
 (0)