Re: usleep feature for pgbench

Поиск
Список
Период
Сортировка
От Jan Wieck
Тема Re: usleep feature for pgbench
Дата
Msg-id 468D57F3.7030405@Yahoo.com
обсуждение исходный текст
Ответ на Re: usleep feature for pgbench  (Tom Lane <tgl@sss.pgh.pa.us>)
Ответы Re: usleep feature for pgbench
Список pgsql-hackers
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
multipleclients 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 #


В списке pgsql-hackers по дате отправления:

Предыдущее
От: "Florian G. Pflug"
Дата:
Сообщение: Re: [PATCH] A crash and subsequent recovery of themaster can cause the slave to get out-of-sync
Следующее
От: Heikki Linnakangas
Дата:
Сообщение: Bgwriter strategies