Skip site navigation (1) Skip section navigation (2)

Re: multi-threaded pgbench

From: Itagaki Takahiro <itagaki(dot)takahiro(at)oss(dot)ntt(dot)co(dot)jp>
To: Andrew Dunstan <andrew(at)dunslane(dot)net>, pgsql-hackers(at)postgresql(dot)org
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Heikki Linnakangas <heikki(dot)linnakangas(at)enterprisedb(dot)com>, Alvaro Herrera <alvherre(at)commandprompt(dot)com>
Subject: Re: multi-threaded pgbench
Date: 2009-07-09 08:51:18
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-hackers
Here is an updated version of multi-threaded pgbench patch.

Andrew Dunstan <andrew(at)dunslane(dot)net> wrote:

> > Hmm, but how will you communicate stats back from the sub-processes?
> My first reaction is to say "use a pipe."

I added partial implementation of pthread using fork and pipe for platform
without ENABLE_THREAD_SAFETY. Pthread version is not necessarily needed
if we have the fork version, but I still left it as-is.

The name of new option is still -j, that is borrowed from pg_restore
and gmake. They use -j for multi-worker-processing.

  -j NUM       number of threads (default: 1)

I needed to modify the meaning of tps (excluding connections establishing)
a little because connections are executed in parallel. I subtract average
of connection times from total execution time.

    total_time := last_thread_finish_time - first_thread_start_time
    tps (including connection) := num_transaction / total_time
    tps (excluding connection) := num_transaction /
                    (total_time - (total_connection_time / num_threads))

I notice that I also fixed a few parts of pgbench:
  * Use instr_time instead of struct timeval.
    Macros in portability/instr_time.h makes codes cleaner.
  * Accept "\sleep 1ms" format (no spaces between "1" and "ms") for sleep
    meta command. The old version of pgbench interprets "1ms" as just "1",
    that means "1 s". It was confusable.

I'll add the patch to the commitfest page.

ITAGAKI Takahiro
NTT Open Source Software Center

Attachment: pgbench-mt_20090709.patch
Description: application/octet-stream (38.7 KB)

In response to


pgsql-hackers by date

Next:From: Noah MischDate: 2009-07-09 12:23:28
Subject: Re: *_collapse_limit, geqo_threshold
Previous:From: Dave PageDate: 2009-07-09 07:58:14
Subject: Re: modules missing from Application Stack Wizard?

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group