On 7/5/2007 3:34 PM, Tom Lane wrote:
Jan Wieck <[EMAIL PROTECTED]> 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.                                  #
#================================================== [EMAIL PROTECTED] #

---------------------------(end of broadcast)---------------------------
TIP 2: Don't 'kill -9' the postmaster

Reply via email to