Commit Graph

142 Commits

Author SHA1 Message Date
Bruce Momjian e126958c2e Update copyright notices for year 2012. 2012-01-01 18:01:58 -05:00
Peter Eisentraut 037a82704c Standardize treatment of strcmp() return value
Always compare the return value to 0, don't use cute tricks like
if (!strcmp(...)).
2011-12-27 21:19:09 +02:00
Tom Lane 5f42e5945b Remove no-longer-used variable. 2011-09-11 16:18:06 -04:00
Robert Haas 68cbb9f4e7 Modestly improve pgbench's checking for invalid ranges.
The old check against MAX_RANDOM_VALUE is clearly irrelevant since
getrand() no longer calls random().  Instead, check whether min and max
are close enough together to avoid an overflow inside getrand(), as
suggested by Tom Lane.  This is still somewhat silly, because we're
using atoi(), which doesn't check for overflow anyway and (at least on
my system) will cheerfully return 0 when given "4294967296".  But that's
a problem for another commit.
2011-08-05 12:53:03 -04:00
Robert Haas 4af43ee3f1 Make pgbench use erand48() rather than random().
glibc renders random() thread-safe by wrapping a futex lock around it;
testing reveals that this limits the performance of pgbench on machines
with many CPU cores.  Rather than switching to random_r(), which is
only available on GNU systems and crashes unless you use undocumented
alchemy to initialize the random state properly, switch to our built-in
implementation of erand48(), which is both thread-safe and concurrent.

Since the list of reasons not to use the operating system's erand48()
is getting rather long, rename ours to pg_erand48() (and similarly
for our implementations of lrand48() and srand48()) and just always
use those.  We were already doing this on Cygwin anyway, and the
glibc implementation is not quite thread-safe, so pgbench wouldn't
be able to use that either.

Per discussion with Tom Lane.
2011-08-03 16:26:40 -04:00
Robert Haas 60fb25a3f5 Move new pgbench options to correct section of --help output. 2011-07-29 16:43:57 -04:00
Robert Haas 7c26395661 Add new pgbench options, --tablespace and --index-tablespace.
Per a request from Greg Smith.
2011-07-25 09:16:14 -04:00
Robert Haas 2d6fee09eb Add new pgbench switch, --unlogged-tables.
This entails adjusting pgbench to use getopt_long() rather
than getopt().
2011-07-25 06:55:12 -04:00
Peter Eisentraut 94a8fde403 Put options help in alphabetical order 2011-05-10 21:48:07 +03:00
Bruce Momjian bf50caf105 pgindent run before PG 9.1 beta 1. 2011-04-10 11:42:00 -04:00
Bruce Momjian d7a714828f Use consistent spacing for PGAPPICON Makefile option. 2011-01-24 20:46:30 -05:00
Bruce Momjian 5d950e3b0c Stamp copyrights for year 2011. 2011-01-01 13:18:15 -05:00
Magnus Hagander fe9b36fd59 Convert cvsignore to gitignore, and add .gitignore for build targets. 2010-09-22 12:57:04 +02:00
Magnus Hagander 9f2e211386 Remove cvs keywords from all files. 2010-09-20 22:08:53 +02:00
Tom Lane 00f76dbffa Get rid of a bunch of dubious error handling code in pgbench by just erroring
out immediately on any out-of-memory condition.  It's rather pointless to
imagine that pgbench will be able to continue usefully after a malloc
failure, and in any case there were a number of unchecked mallocs.
2010-08-12 21:10:59 +00:00
Tom Lane 5a4e19abe6 Add the ability to compute per-statement latencies (ie, average execution
times) to pgbench.

Florian Pflug, reviewed by Greg Smith
2010-08-12 20:39:39 +00:00
Bruce Momjian 239d769e7e pgindent run for 9.0, second run 2010-07-06 19:19:02 +00:00
Bruce Momjian 395d1259ad Add PGFILEDESC description to Makefiles for all /contrib executables.
Add PGAPPICON to all executable makefiles.
2010-05-12 11:33:10 +00:00
Itagaki Takahiro a887c486d5 Each worker thread will have its own log file in pgbench to avoid interleaved
writes. The first worker still uses "pgbench_log.<pid>" for the name, but
additional workers use "pgbench_log.<pid>.<serial-number>" instead.

Reported by Greg Smith.
2010-03-23 01:29:22 +00:00
Bruce Momjian 65e806cba1 pgindent run for 9.0 2010-02-26 02:01:40 +00:00
Itagaki Takahiro a8a198b10b Adjust headers to allow pgbench to be built with PGXS. 2010-01-06 01:30:03 +00:00
Itagaki Takahiro 660f532898 Add verification of variable names in pgbench.
Variables must consist of only alphabets, numerals and underscores.
We had allowed to set variables with invalid names, but could not
refer them in queries.

Thanks to Robert Haas for the review.
2010-01-06 01:12:14 +00:00
Bruce Momjian 0239800893 Update copyright for the year 2010. 2010-01-02 16:58:17 +00:00
Itagaki Takahiro 7d67e06297 Add \shell and \setshell meta commands to pgbench.
\shell command runs an external shell command.
\setshell also does the same and sets the result to a variable.

original patch by Michael Paquier with some editorialization by Itagaki,
and reviewed by Greg Smith.
2009-12-15 07:17:57 +00:00
Tom Lane 6b45e3b7aa Arrange to generate different random sequences in the different child
processes of a pgbench run, when we are using -j > 1 and are emulating
threads via fork().  Otherwise the children all inherit the same random
sequence state and produce the same random-number sequence.

In the threaded case the different threads will share one RNG state, so
they will produce different subsets of one sequence, which is maybe more
correlated than a purist would like but will not be "the same".  So we
leave that case alone.

First noticed by Takahiro Itagaki, and is also part of the explanation
for the pgbench misbehavior recently reported by Jaime Casanova.
2009-12-11 21:50:06 +00:00
Tatsuo Ishii f82d4d5302 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.

Patch provided by Jeff Janes.
2009-09-10 13:59:57 +00:00
Tom Lane 7ffb14f9db Portability and documentation fixes for threaded pgbench patch. 2009-08-03 18:30:55 +00:00
Tatsuo Ishii 3da0dfb4b1 Multi-threaded version of pgbench contributed by ITAGAKI Takahiro,
reviewed by Greg Smith and Josh Williams.

Following is the proposal from ITAGAKI Takahiro:

Pgbench is a famous tool to measure postgres performance, but nowadays
it does not work well because it cannot use multiple CPUs. On the other
hand, postgres server can use CPUs very well, so the bottle-neck of
workload is *in pgbench*.

Multi-threading would be a solution. The attached patch adds -j
(number of jobs) option to pgbench. If the value N is greater than 1,
pgbench runs with N threads. Connections are equally-divided into
them (ex. -c64 -j4 => 4 threads with 16 connections each). It can
run on POSIX platforms with pthread and on Windows with win32 threads.

Here are results of multi-threaded pgbench runs on Fedora 11 with intel
core i7 (8 logical cores = 4 physical cores * HT). -j8 (8 threads) was
the best and the tps is 4.5 times of -j1, that is a traditional result.

$ pgbench -i -s10
$ pgbench -n -S -c64 -j1   =>  tps = 11600.158593
$ pgbench -n -S -c64 -j2   =>  tps = 17947.100954
$ pgbench -n -S -c64 -j4   =>  tps = 26571.124001
$ pgbench -n -S -c64 -j8   =>  tps = 52725.470403
$ pgbench -n -S -c64 -j16  =>  tps = 38976.675319
$ pgbench -n -S -c64 -j32  =>  tps = 28998.499601
$ pgbench -n -S -c64 -j64  =>  tps = 26701.877815

Is it acceptable to use pthread in contrib module?
If ok, I will add the patch to the next commitfest.
2009-08-03 15:18:14 +00:00
Magnus Hagander a23c641578 Make sure FD_SETSIZE is set before we include any Windows
header files.

Josh Williams
2009-07-30 09:28:00 +00:00
Bruce Momjian d747140279 8.4 pgindent run, with new combined Linux/FreeBSD/MinGW typedef list
provided by Andrew.
2009-06-11 14:49:15 +00:00
Tom Lane 48caf91b66 Change pgbench to use the table names pgbench_accounts, pgbench_branches,
pgbench_history, and pgbench_tellers, rather than just accounts, branches,
history, and tellers.  This is to prevent accidental conflicts with real
application tables, as has been reported to happen at least once.  Also
remove the automatic "SET search_path = public" that it did at startup,
as this seems to restrict testing flexibility without actually buying much.
Per proposal by Joshua Drake and ensuing discussion.

Joshua Drake and Tom Lane
2009-05-07 22:01:18 +00:00
Peter Eisentraut b6e4c8f255 Equip the programs installed by contrib with proper --help and --version
options and normally formatted help output.
2009-02-27 09:30:21 +00:00
Peter Eisentraut a3c502c89f Remove feof(stdin) calls related to when to prompt for a password,
leftovers from when the password was read from stdin.
2009-02-25 13:24:40 +00:00
Tatsuo Ishii 40e01e267d Remove outdated Japanese README files per discussion. 2009-01-06 13:43:31 +00:00
Bruce Momjian 511db38ace Update copyright for 2009. 2009-01-01 17:24:05 +00:00
Tom Lane cff4aa6ad6 Add a duration option to pgbench, so that test length can be specified in seconds
instead of by number of transactions to run.  Takahiro Itagaki
2008-09-11 23:52:48 +00:00
Bruce Momjian 6152de97d3 Minor patch on pgbench
1. -i option should run vacuum analyze only on pgbench tables, not *all*
tables in database.

2. pre-run cleanup step was DELETE FROM HISTORY then VACUUM HISTORY.
This is just a slow version of TRUNCATE HISTORY.

Simon Riggs
2008-08-22 17:57:34 +00:00
Tom Lane 6b1b4641b8 Give a warning if -s switch is used with a non-custom pgbench test.
Also, clean up the code that assigned the scale into :scale variables.
Greg Smith and Tom Lane
2008-05-09 15:53:07 +00:00
Tatsuo Ishii 49639a7b2c Add -M (query mode) option per ITAGAKI Takahiro 2008-03-19 03:33:21 +00:00
Tatsuo Ishii f755f2fef3 Fix tps calculation when -C supplied. Per Yoshiyuki Asaba.
Change Copyright owner from mine to PostgreSQL Global Development Group
Fix minor message typo
2008-03-19 00:29:35 +00:00
Tom Lane b7a67c2840 Add a comment explaining one of the ways that pgbench fails to fully
comply with TPC-B.  Per Itagaki Takahiro and discussion of bug#3681.
2008-03-12 02:18:33 +00:00
Tom Lane 9537739f7f Fix pgbench's getrand() function so that min and max have approximately
the same chance of being selected as do numbers between them.  Problem
noted by Greg Stark; fix by Alexey Klyukin.
2008-03-10 01:23:04 +00:00
Tom Lane 4192f2d85a Remove the -P options of oid2name and pgbench, as they are security
hazards.  Instead teach these programs to prompt for a password when
necessary, just like all our other programs.
I did not bother to invent -W switches for them, since the return on
investment seems so low.
2007-12-11 02:31:49 +00:00
Bruce Momjian fdf5a5efb7 pgindent run for 8.3. 2007-11-15 21:14:46 +00:00
Bruce Momjian 541ff409cc Remove references to READMEs from /contrib Makefiles. 2007-11-10 23:59:52 +00:00
Bruce Momjian c3c69ab4fd Move most /contrib README files into SGML. Some still need conversion
or will never be converted.
2007-11-10 23:30:46 +00:00
Magnus Hagander f04b8a8e2c Increase FD_SETSIZE on Win32 to allow for more than 54 clients.
Per Greg Stark & Dave Page
2007-10-22 10:40:47 +00:00
Tom Lane ffda674769 Tweak pgbench.c to remove the hidden assumption that a WIN32 machine
couldn't possibly HAVE_GETOPT.  I believe this is the most appropriate
form of the patch submitted 2007-08-07 by Hiroshi Saito, though not
having a Windows build environment I won't know for sure till I see
the buildfarm results.
2007-09-27 20:39:43 +00:00
Tatsuo Ishii e4a52eca35 The upper limit for -c option of pgbench is now obtained from
(FD_SETSIZE - 10) rather than a hardwired number.
2007-08-25 09:21:14 +00:00
Tom Lane d097534219 Fix possible core dump from pgbench -d option. Julius Stroffek 2007-08-22 23:03:27 +00:00