]> granicus.if.org Git - postgresql/commitdiff
Two fixes from Tom Lan. See the posting "[PATCHES] A couple of
authorTatsuo Ishii <ishii@postgresql.org>
Sun, 4 Dec 2005 01:22:42 +0000 (01:22 +0000)
committerTatsuo Ishii <ishii@postgresql.org>
Sun, 4 Dec 2005 01:22:42 +0000 (01:22 +0000)
proposed pgbench changes" on 2005/11/29 for more details.

The change at line 490 updates doCustom's local variable "commands"
after selecting a new file (command sequence).  I think that the
existing coding will cause the thing to use the first command of the
old sequence in the remainder of the routine, which would be a bug.
I have not tried to set up a test case to prove it, though.

The other two changes cause doCustom to loop after processing a
meta-command.  This might be a bit controversial, but as the code
is currently written, each meta-command "costs" one cycle of the
outer select() loop.  Thus, for example, with the default TPC-B script,
once a backend returns "COMMIT" it will not receive a new command
until four cycles of issuing commands to other backends have elapsed.
(You can see this very easily by strace'ing pgbench under load.)

contrib/pgbench/pgbench.c

index 8e999630330e1436b627867be83f5a9a26cf8a25..ae8c4fe5e4159f4919925e826419c4db1eb6ad0a 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $PostgreSQL: pgsql/contrib/pgbench/pgbench.c,v 1.45.2.2 2005/11/23 13:23:34 ishii Exp $
+ * $PostgreSQL: pgsql/contrib/pgbench/pgbench.c,v 1.45.2.3 2005/12/04 01:22:42 ishii Exp $
  *
  * pgbench: a simple benchmark program for PostgreSQL
  * written by Tatsuo Ishii
@@ -411,6 +411,7 @@ doCustom(CState * state, int n, int debug)
        CState     *st = &state[n];
        Command   **commands;
 
+top:
        commands = sql_files[st->use_file];
 
        if (st->listen)
@@ -489,6 +490,7 @@ doCustom(CState * state, int n, int debug)
                {
                        st->state = 0;
                        st->use_file = getrand(0, num_files - 1);
+                       commands = sql_files[st->use_file];
                }
        }
 
@@ -572,6 +574,8 @@ doCustom(CState * state, int n, int debug)
                        free(val);
                        st->listen = 1;
                }
+
+               goto top;
        }
 }