@@ -90,7 +90,7 @@ static int pthread_join(pthread_t th, void **thread_return);
90
90
#define LOG_STEP_SECONDS 5 /* seconds between log messages */
91
91
#define DEFAULT_NXACTS 10 /* default nxacts */
92
92
93
- #define MIN_GAUSSIAN_PARAM 2.0 /* minimum parameter for gauss */
93
+ #define MIN_GAUSSIAN_PARAM 2.0 /* minimum parameter for gauss */
94
94
95
95
int nxacts = 0 ; /* number of transactions per client */
96
96
int duration = 0 ; /* duration in seconds */
@@ -201,16 +201,15 @@ typedef struct
201
201
PGconn * con ; /* connection handle to DB */
202
202
int id ; /* client No. */
203
203
int state ; /* state No. */
204
- int listen ; /* 0 indicates that an async query has been
205
- * sent */
206
- int sleeping ; /* 1 indicates that the client is napping */
204
+ bool listen ; /* whether an async query has been sent */
205
+ bool is_throttled ; /* whether transaction throttling is done */
206
+ bool sleeping ; /* whether the client is napping */
207
207
bool throttling ; /* whether nap is for throttling */
208
208
Variable * variables ; /* array of variable definitions */
209
209
int nvariables ;
210
210
int64 txn_scheduled ; /* scheduled start time of transaction (usec) */
211
211
instr_time txn_begin ; /* used for measuring schedule lag times */
212
212
instr_time stmt_begin ; /* used for measuring statement latencies */
213
- bool is_throttled ; /* whether transaction throttling is done */
214
213
int use_file ; /* index in sql_files for this client */
215
214
bool prepared [MAX_FILES ];
216
215
@@ -374,7 +373,7 @@ usage(void)
374
373
" -f, --file=FILENAME read transaction script from FILENAME\n"
375
374
" -j, --jobs=NUM number of threads (default: 1)\n"
376
375
" -l, --log write transaction times to log file\n"
377
- " -L, --latency-limit=NUM count transactions lasting more than NUM ms as late\n"
376
+ " -L, --latency-limit=NUM count transactions lasting more than NUM ms as late\n"
378
377
" -M, --protocol=simple|extended|prepared\n"
379
378
" protocol for submitting queries (default: simple)\n"
380
379
" -n, --no-vacuum do not run VACUUM before tests\n"
@@ -389,7 +388,7 @@ usage(void)
389
388
" -v, --vacuum-all vacuum all four standard tables before tests\n"
390
389
" --aggregate-interval=NUM aggregate data over NUM seconds\n"
391
390
" --sampling-rate=NUM fraction of transactions to log (e.g. 0.01 for 1%%)\n"
392
- " --progress-timestamp use Unix epoch timestamps for progress\n"
391
+ " --progress-timestamp use Unix epoch timestamps for progress\n"
393
392
"\nCommon options:\n"
394
393
" -d, --debug print debugging output\n"
395
394
" -h, --host=HOSTNAME database server host or socket directory\n"
@@ -520,16 +519,16 @@ getGaussianRand(TState *thread, int64 min, int64 max, double parameter)
520
519
double rand ;
521
520
522
521
/*
523
- * Get user specified random number from this loop,
524
- * with -parameter < stdev <= parameter
522
+ * Get user specified random number from this loop, with -parameter <
523
+ * stdev <= parameter
525
524
*
526
525
* This loop is executed until the number is in the expected range.
527
526
*
528
527
* As the minimum parameter is 2.0, the probability of looping is low:
529
528
* sqrt(-2 ln(r)) <= 2 => r >= e^{-2} ~ 0.135, then when taking the
530
529
* average sinus multiplier as 2/pi, we have a 8.6% looping probability in
531
- * the worst case. For a parameter value of 5.0, the looping probability is
532
- * about e^{-5} * 2 / pi ~ 0.43%.
530
+ * the worst case. For a parameter value of 5.0, the looping probability
531
+ * is about e^{-5} * 2 / pi ~ 0.43%.
533
532
*/
534
533
do
535
534
{
@@ -1191,7 +1190,7 @@ doCustom(TState *thread, CState *st, instr_time *conn_time, FILE *logfile, AggVa
1191
1190
}
1192
1191
}
1193
1192
1194
- st -> sleeping = 1 ;
1193
+ st -> sleeping = true ;
1195
1194
st -> throttling = true;
1196
1195
st -> is_throttled = true;
1197
1196
if (debug )
@@ -1208,7 +1207,8 @@ doCustom(TState *thread, CState *st, instr_time *conn_time, FILE *logfile, AggVa
1208
1207
now_us = INSTR_TIME_GET_MICROSEC (now );
1209
1208
if (st -> txn_scheduled <= now_us )
1210
1209
{
1211
- st -> sleeping = 0 ; /* Done sleeping, go ahead with next command */
1210
+ /* Done sleeping, go ahead with next command */
1211
+ st -> sleeping = false;
1212
1212
if (st -> throttling )
1213
1213
{
1214
1214
/* Measure lag of throttled transaction relative to target */
@@ -1337,9 +1337,9 @@ doCustom(TState *thread, CState *st, instr_time *conn_time, FILE *logfile, AggVa
1337
1337
* nothing to listen to right now. When throttling rate limits
1338
1338
* are active, a sleep will happen next, as the next transaction
1339
1339
* starts. And then in any case the next SQL command will set
1340
- * listen back to 1 .
1340
+ * listen back to true .
1341
1341
*/
1342
- st -> listen = 0 ;
1342
+ st -> listen = false ;
1343
1343
trans_needs_throttle = (throttle_delay > 0 );
1344
1344
}
1345
1345
}
@@ -1462,7 +1462,7 @@ doCustom(TState *thread, CState *st, instr_time *conn_time, FILE *logfile, AggVa
1462
1462
st -> ecnt ++ ;
1463
1463
}
1464
1464
else
1465
- st -> listen = 1 ; /* flags that should be listened */
1465
+ st -> listen = true ; /* flags that should be listened */
1466
1466
}
1467
1467
else if (commands [st -> state ]-> type == META_COMMAND )
1468
1468
{
@@ -1585,8 +1585,8 @@ doCustom(TState *thread, CState *st, instr_time *conn_time, FILE *logfile, AggVa
1585
1585
if (parameter <= 0.0 )
1586
1586
{
1587
1587
fprintf (stderr ,
1588
- "exponential parameter must be greater than zero (not \"%s\")\n" ,
1589
- argv [5 ]);
1588
+ "exponential parameter must be greater than zero (not \"%s\")\n" ,
1589
+ argv [5 ]);
1590
1590
st -> ecnt ++ ;
1591
1591
return true;
1592
1592
}
@@ -1613,7 +1613,7 @@ doCustom(TState *thread, CState *st, instr_time *conn_time, FILE *logfile, AggVa
1613
1613
return true;
1614
1614
}
1615
1615
1616
- st -> listen = 1 ;
1616
+ st -> listen = true ;
1617
1617
}
1618
1618
else if (pg_strcasecmp (argv [0 ], "set" ) == 0 )
1619
1619
{
@@ -1634,7 +1634,7 @@ doCustom(TState *thread, CState *st, instr_time *conn_time, FILE *logfile, AggVa
1634
1634
return true;
1635
1635
}
1636
1636
1637
- st -> listen = 1 ;
1637
+ st -> listen = true ;
1638
1638
}
1639
1639
else if (pg_strcasecmp (argv [0 ], "sleep" ) == 0 )
1640
1640
{
@@ -1668,9 +1668,9 @@ doCustom(TState *thread, CState *st, instr_time *conn_time, FILE *logfile, AggVa
1668
1668
1669
1669
INSTR_TIME_SET_CURRENT (now );
1670
1670
st -> txn_scheduled = INSTR_TIME_GET_MICROSEC (now ) + usec ;
1671
- st -> sleeping = 1 ;
1671
+ st -> sleeping = true ;
1672
1672
1673
- st -> listen = 1 ;
1673
+ st -> listen = true ;
1674
1674
}
1675
1675
else if (pg_strcasecmp (argv [0 ], "setshell" ) == 0 )
1676
1676
{
@@ -1684,7 +1684,7 @@ doCustom(TState *thread, CState *st, instr_time *conn_time, FILE *logfile, AggVa
1684
1684
return true;
1685
1685
}
1686
1686
else /* succeeded */
1687
- st -> listen = 1 ;
1687
+ st -> listen = true ;
1688
1688
}
1689
1689
else if (pg_strcasecmp (argv [0 ], "shell" ) == 0 )
1690
1690
{
@@ -1698,7 +1698,7 @@ doCustom(TState *thread, CState *st, instr_time *conn_time, FILE *logfile, AggVa
1698
1698
return true;
1699
1699
}
1700
1700
else /* succeeded */
1701
- st -> listen = 1 ;
1701
+ st -> listen = true ;
1702
1702
}
1703
1703
goto top ;
1704
1704
}
@@ -2207,7 +2207,8 @@ parseQuery(Command *cmd, const char *raw_sql)
2207
2207
return true;
2208
2208
}
2209
2209
2210
- void pg_attribute_noreturn ()
2210
+ void
2211
+ pg_attribute_noreturn ()
2211
2212
syntax_error (const char * source , const int lineno ,
2212
2213
const char * line , const char * command ,
2213
2214
const char * msg , const char * more , const int column )
@@ -2289,10 +2290,10 @@ process_commands(char *buf, const char *source, const int lineno)
2289
2290
2290
2291
if (pg_strcasecmp (my_commands -> argv [0 ], "setrandom" ) == 0 )
2291
2292
{
2292
- /*
2293
+ /*--------
2293
2294
* parsing:
2294
- * \setrandom variable min max [uniform]
2295
- * \setrandom variable min max (gaussian|exponential) parameter
2295
+ * \setrandom variable min max [uniform]
2296
+ * \setrandom variable min max (gaussian|exponential) parameter
2296
2297
*/
2297
2298
2298
2299
if (my_commands -> argc < 4 )
@@ -2317,7 +2318,7 @@ process_commands(char *buf, const char *source, const int lineno)
2317
2318
if (my_commands -> argc < 6 )
2318
2319
{
2319
2320
syntax_error (source , lineno , my_commands -> line , my_commands -> argv [0 ],
2320
- "missing parameter" , my_commands -> argv [4 ], -1 );
2321
+ "missing parameter" , my_commands -> argv [4 ], -1 );
2321
2322
}
2322
2323
else if (my_commands -> argc > 6 )
2323
2324
{
@@ -2762,12 +2763,14 @@ main(int argc, char **argv)
2762
2763
{"initialize" , no_argument , NULL , 'i' },
2763
2764
{"jobs" , required_argument , NULL , 'j' },
2764
2765
{"log" , no_argument , NULL , 'l' },
2766
+ {"latency-limit" , required_argument , NULL , 'L' },
2765
2767
{"no-vacuum" , no_argument , NULL , 'n' },
2766
2768
{"port" , required_argument , NULL , 'p' },
2767
2769
{"progress" , required_argument , NULL , 'P' },
2768
2770
{"protocol" , required_argument , NULL , 'M' },
2769
2771
{"quiet" , no_argument , NULL , 'q' },
2770
2772
{"report-latencies" , no_argument , NULL , 'r' },
2773
+ {"rate" , required_argument , NULL , 'R' },
2771
2774
{"scale" , required_argument , NULL , 's' },
2772
2775
{"select-only" , no_argument , NULL , 'S' },
2773
2776
{"skip-some-updates" , no_argument , NULL , 'N' },
@@ -2782,8 +2785,6 @@ main(int argc, char **argv)
2782
2785
{"unlogged-tables" , no_argument , & unlogged_tables , 1 },
2783
2786
{"sampling-rate" , required_argument , NULL , 4 },
2784
2787
{"aggregate-interval" , required_argument , NULL , 5 },
2785
- {"rate" , required_argument , NULL , 'R' },
2786
- {"latency-limit" , required_argument , NULL , 'L' },
2787
2788
{"progress-timestamp" , no_argument , NULL , 6 },
2788
2789
{NULL , 0 , NULL , 0 }
2789
2790
};
@@ -3627,7 +3628,7 @@ threadRun(void *arg)
3627
3628
{
3628
3629
/* interrupt client which has not started a transaction */
3629
3630
remains -- ;
3630
- st -> sleeping = 0 ;
3631
+ st -> sleeping = false ;
3631
3632
st -> throttling = false;
3632
3633
PQfinish (st -> con );
3633
3634
st -> con = NULL ;
0 commit comments