pgsql: Multi-threaded version of pgbench contributed by ITAGAKI - Mailing list pgsql-committers

From ishii@postgresql.org (Tatsuo Ishii)
Subject pgsql: Multi-threaded version of pgbench contributed by ITAGAKI
Date
Msg-id 20090803151814.E331375331E@cvs.postgresql.org
Whole thread Raw
List pgsql-committers
Log Message:
-----------
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.

Modified Files:
--------------
    pgsql/contrib/pgbench:
        pgbench.c (r1.88 -> r1.89)
        (http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/contrib/pgbench/pgbench.c?r1=1.88&r2=1.89)
    pgsql/doc/src/sgml:
        pgbench.sgml (r1.8 -> r1.9)
        (http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/doc/src/sgml/pgbench.sgml?r1=1.8&r2=1.9)

pgsql-committers by date:

Previous
From: bmomjian@pgfoundry.org (User Bmomjian)
Date:
Subject: pg-migrator - pg_migrator: Update EDB documentation.
Next
From: tgl@postgresql.org (Tom Lane)
Date:
Subject: pgsql: Portability and documentation fixes for threaded pgbench patch.