Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit8229d85

Browse files
author
Marina Polyakova
committed
Pgbench Report per-command serialization and deadlock failures
They are reported if you use --default-isolation-level (-I) benchmarking optionor if per-script/command statistics is reported as usual.
1 parent43e5346 commit8229d85

File tree

1 file changed

+36
-11
lines changed

1 file changed

+36
-11
lines changed

‎src/bin/pgbench/pgbench.c

Lines changed: 36 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -323,6 +323,10 @@ typedef struct
323323
char*argv[MAX_ARGS];/* command word list */
324324
PgBenchExpr*expr;/* parsed expression, if needed */
325325
SimpleStatsstats;/* time spent in this command */
326+
int64serialization_failures;/* number of serialization failures in
327+
* this command */
328+
int64deadlock_failures;/* number of deadlock failures in this
329+
* command */
326330
}Command;
327331

328332
typedefstructParsedScript
@@ -1970,6 +1974,15 @@ doCustom(TState *thread, CState *st, StatsData *agg)
19701974
INSTR_TIME_GET_DOUBLE(st->stmt_begin));
19711975
}
19721976

1977+
/*
1978+
* accumulate per-command serialization / deadlock failures count in
1979+
* thread-local data structure
1980+
*/
1981+
if (serialization_failure)
1982+
commands[st->state]->serialization_failures++;
1983+
if (deadlock_failure)
1984+
commands[st->state]->deadlock_failures++;
1985+
19731986
/* transaction finished: calculate latency and log the transaction */
19741987
if (commands[st->state+1]==NULL)
19751988
{
@@ -2877,6 +2890,8 @@ process_sql_command(PQExpBuffer buf, const char *source)
28772890
my_command->type=SQL_COMMAND;
28782891
my_command->argc=0;
28792892
initSimpleStats(&my_command->stats);
2893+
my_command->serialization_failures=0;
2894+
my_command->deadlock_failures=0;
28802895

28812896
/*
28822897
* If SQL command is multi-line, we only want to save the first line as
@@ -2946,6 +2961,8 @@ process_backslash_command(PsqlScanState sstate, const char *source)
29462961
my_command->type=META_COMMAND;
29472962
my_command->argc=0;
29482963
initSimpleStats(&my_command->stats);
2964+
my_command->serialization_failures=0;
2965+
my_command->deadlock_failures=0;
29492966

29502967
/* Save first word (command name) */
29512968
j=0;
@@ -3462,6 +3479,7 @@ printResults(TState *threads, StatsData *total, instr_time total_time,
34623479
if (per_script_stats||latency_limit||is_latencies)
34633480
{
34643481
inti;
3482+
Command**commands;
34653483

34663484
for (i=0;i<num_scripts;i++)
34673485
{
@@ -3497,20 +3515,26 @@ printResults(TState *threads, StatsData *total, instr_time total_time,
34973515
if (num_scripts>1)
34983516
printSimpleStats(" - latency",&sql_script[i].stats.latency);
34993517

3500-
/* Report per-command latencies */
3518+
/*
3519+
* Report per-command serialization / deadlock failures and
3520+
* latencies (if needed). */
35013521
if (is_latencies)
3502-
{
3503-
Command**commands;
3504-
3505-
printf(" - statement latencies in milliseconds:\n");
3522+
printf(" - statement serialization, deadlock failures and latencies in milliseconds:\n");
3523+
else
3524+
printf(" - statement serialization and deadlock failures:\n");
35063525

3507-
for (commands=sql_script[i].commands;
3508-
*commands!=NULL;
3509-
commands++)
3510-
printf(" %11.3f %s\n",
3526+
for (commands=sql_script[i].commands;
3527+
*commands!=NULL;
3528+
commands++)
3529+
{
3530+
printf(" %25"INT64_MODIFIER"d %25"INT64_MODIFIER"d",
3531+
(*commands)->serialization_failures,
3532+
(*commands)->deadlock_failures);
3533+
if (is_latencies)
3534+
printf(" %11.3f",
35113535
1000.0* (*commands)->stats.sum /
3512-
(*commands)->stats.count,
3513-
(*commands)->line);
3536+
(*commands)->stats.count);
3537+
printf(" %s\n", (*commands)->line);
35143538
}
35153539
}
35163540
}
@@ -3869,6 +3893,7 @@ main(int argc, char **argv)
38693893
case'I':
38703894
{
38713895
benchmarking_option_set= true;
3896+
per_script_stats= true;
38723897

38733898
for (default_isolation_level=0;
38743899
default_isolation_level<NUM_DEFAULT_ISOLATION_LEVEL;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp