pgbench hard coded constants

Started by Jeff Janesover 16 years ago3 messages
#1Jeff Janes
jeff.janes@gmail.com
1 attachment(s)

pgbench has #defines for number of branches, tellers, and accounts. There
are used to populate the tables with -i, but when running actual benchmark
it has values separately hard-coded in the query metacommands. This patch
makes the metacommands obtain their values from the relevant #defines.

It has been tested to the extent that after changing the #define naccounts
downward, without the patch, after running both -i once and the benchmark
itself once leads to inconsistent results (select sum(abalance) from
pgbench_accounts does not equal sum(delta) from pgbench_history), while
with the patch they are equal.

Cheers,

Jeff

Attachments:

pgbench.patchtext/x-diff; charset=US-ASCII; name=pgbench.patchDownload
Index: pgbench.c
===================================================================
RCS file: /home/jjanes/pgrepo/pgsql/contrib/pgbench/pgbench.c,v
retrieving revision 1.90
diff -c -r1.90 pgbench.c
*** pgbench.c	3 Aug 2009 18:30:55 -0000	1.90
--- pgbench.c	31 Aug 2009 21:04:46 -0000
***************
*** 132,138 ****
   * end of configurable parameters
   *********************************************************************/
  
! #define nbranches	1
  #define ntellers	10
  #define naccounts	100000
  
--- 132,138 ----
   * end of configurable parameters
   *********************************************************************/
  
! #define nbranches	1  /* Makes little sense to change this.  Change -s instead */
  #define ntellers	10
  #define naccounts	100000
  
***************
*** 232,240 ****
  
  /* default scenario */
  static char *tpc_b = {
! 	"\\set nbranches :scale\n"
! 	"\\set ntellers 10 * :scale\n"
! 	"\\set naccounts 100000 * :scale\n"
  	"\\setrandom aid 1 :naccounts\n"
  	"\\setrandom bid 1 :nbranches\n"
  	"\\setrandom tid 1 :ntellers\n"
--- 232,240 ----
  
  /* default scenario */
  static char *tpc_b = {
! 	"\\set nbranches " CppAsString2(nbranches) " * :scale\n"
! 	"\\set ntellers " CppAsString2(ntellers) " * :scale\n"
! 	"\\set naccounts " CppAsString2(naccounts) " * :scale\n"
  	"\\setrandom aid 1 :naccounts\n"
  	"\\setrandom bid 1 :nbranches\n"
  	"\\setrandom tid 1 :ntellers\n"
***************
*** 250,258 ****
  
  /* -N case */
  static char *simple_update = {
! 	"\\set nbranches :scale\n"
! 	"\\set ntellers 10 * :scale\n"
! 	"\\set naccounts 100000 * :scale\n"
  	"\\setrandom aid 1 :naccounts\n"
  	"\\setrandom bid 1 :nbranches\n"
  	"\\setrandom tid 1 :ntellers\n"
--- 250,258 ----
  
  /* -N case */
  static char *simple_update = {
! 	"\\set nbranches " CppAsString2(nbranches) " * :scale\n"
! 	"\\set ntellers " CppAsString2(ntellers) " * :scale\n"
! 	"\\set naccounts " CppAsString2(naccounts) " * :scale\n"
  	"\\setrandom aid 1 :naccounts\n"
  	"\\setrandom bid 1 :nbranches\n"
  	"\\setrandom tid 1 :ntellers\n"
***************
*** 266,272 ****
  
  /* -S case */
  static char *select_only = {
! 	"\\set naccounts 100000 * :scale\n"
  	"\\setrandom aid 1 :naccounts\n"
  	"SELECT abalance FROM pgbench_accounts WHERE aid = :aid;\n"
  };
--- 266,272 ----
  
  /* -S case */
  static char *select_only = {
! 	"\\set naccounts " CppAsString2(naccounts) " * :scale\n"
  	"\\setrandom aid 1 :naccounts\n"
  	"SELECT abalance FROM pgbench_accounts WHERE aid = :aid;\n"
  };
#2Tatsuo Ishii
ishii@postgresql.org
In reply to: Jeff Janes (#1)
Re: pgbench hard coded constants

pgbench has #defines for number of branches, tellers, and accounts. There
are used to populate the tables with -i, but when running actual benchmark
it has values separately hard-coded in the query metacommands. This patch
makes the metacommands obtain their values from the relevant #defines.

Good catch! Long standing bug...

It has been tested to the extent that after changing the #define naccounts
downward, without the patch, after running both -i once and the benchmark
itself once leads to inconsistent results (select sum(abalance) from
pgbench_accounts does not equal sum(delta) from pgbench_history), while
with the patch they are equal.

Looks good. If there's no objection, I will commit into CVS HEAD.
--
Tatsuo Ishii
SRA OSS, Inc. Japan

#3Tatsuo Ishii
ishii@postgresql.org
In reply to: Tatsuo Ishii (#2)
Re: pgbench hard coded constants

pgbench has #defines for number of branches, tellers, and accounts. There
are used to populate the tables with -i, but when running actual benchmark
it has values separately hard-coded in the query metacommands. This patch
makes the metacommands obtain their values from the relevant #defines.

Good catch! Long standing bug...

It has been tested to the extent that after changing the #define naccounts
downward, without the patch, after running both -i once and the benchmark
itself once leads to inconsistent results (select sum(abalance) from
pgbench_accounts does not equal sum(delta) from pgbench_history), while
with the patch they are equal.

Looks good. If there's no objection, I will commit into CVS HEAD.

Done. Thanks Jeff!
--
Tatsuo Ishii
SRA OSS, Inc. Japan