Re: multi-threaded pgbench - Mailing list pgsql-hackers

From Itagaki Takahiro
Subject Re: multi-threaded pgbench
Date
Msg-id 20090709172254.98BC.52131E4D@oss.ntt.co.jp
Whole thread Raw
In response to Re: multi-threaded pgbench  (Andrew Dunstan <andrew@dunslane.net>)
Responses Re: multi-threaded pgbench
Re: multi-threaded pgbench
List pgsql-hackers
Here is an updated version of multi-threaded pgbench patch.

Andrew Dunstan <andrew@dunslane.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.

Regards,
---
ITAGAKI Takahiro
NTT Open Source Software Center


Attachment

pgsql-hackers by date:

Previous
From: Dave Page
Date:
Subject: Re: modules missing from Application Stack Wizard?
Next
From: Peter Hunsberger
Date:
Subject: Re: *_collapse_limit, geqo_threshold