From: Jan Wieck <JanWieck@Yahoo.com>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: PostgreSQL Development <pgsql-hackers@postgresql.org>
Subject: Re: usleep feature for pgbench
Date: Thu, 05 Jul 2007 16:43:31 -0400
Message-ID: <468D57F3.7030405@Yahoo.com> (raw)
In-Reply-To: <20905.1183664046@sss.pgh.pa.us>
References: <468D42B3.4010701@Yahoo.com>
<20905.1183664046@sss.pgh.pa.us>
On 7/5/2007 3:34 PM, Tom Lane wrote:
> Jan Wieck <JanWieck@Yahoo.com> writes:
>> To test some changes in Slony I needed a
>> \usleep [microseconds|:variable]
>> in pgbench's scripting language to be able to have hundreds of
>> concurrent running transactions without totally swamping the system. I
>> was wondering if anyone would object to permanently adding this to the
>> pgbench code?
>
> How's it implemented? Does the whole pgbench app freeze up for the
> duration of the sleep, or does it just delay that one client script?
Only that one client script.
The \usleep command itself calculates a "struct timeval until" that sits
in the state struct and sets a "sleeping" flag also in the state struct.
So both are per client script/connection and multiple clients can be
sleeping in an overlapping fashion. The loop in main() then picks the
lowest timeval (if there is anyone sleeping) and uses that to calculate
the timeout for select(). doCustom() resets the sleeping flag for those
scheduled for wakeup and advances the client to the next scripted command.
I think I've coded it in a way that if one doesn't use the \usleep
command at all, it will never even call gettimeofday() and use a NULL
timeout in select() as it used to.
Jan
--
#======================================================================#
# It's easier to get forgiveness for being wrong than for being right. #
# Let's break this rule - forgive me. #
#================================================== JanWieck@Yahoo.com #
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-hackers@postgresql.org
Cc: JanWieck@Yahoo.com, tgl@sss.pgh.pa.us
Subject: Re: usleep feature for pgbench
In-Reply-To: <468D57F3.7030405@Yahoo.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox