Received: from localhost (maia-1.hub.org [200.46.204.191]) by postgresql.org (Postfix) with ESMTP id D1E709FB70E for ; Thu, 5 Jul 2007 17:43:52 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.191]) (amavisd-maia, port 10024) with ESMTP id 95899-07 for ; Thu, 5 Jul 2007 17:43:48 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.5 Received: from smtp116.plus.mail.re1.yahoo.com (smtp116.plus.mail.re1.yahoo.com [69.147.102.79]) by postgresql.org (Postfix) with SMTP id A75E99FB7DE for ; Thu, 5 Jul 2007 17:43:48 -0300 (ADT) Received: (qmail 16140 invoked from network); 5 Jul 2007 20:43:47 -0000 DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=Yahoo.com; h=Received:X-YMail-OSG:Received:Message-ID:Date:From:User-Agent:MIME-Version:To:CC:Subject:References:In-Reply-To:Content-Type:Content-Transfer-Encoding; b=zRz5OLUOeclvq1v+eXxDI3kNKSWJpkFUumFM+j6NUPrYE8j2ZPwl1WKByTTuc7yD1hQ1kBMBiVGfAgyRgH6q8LbwgZkylrhD5G8Wb/v7BjpNaWHUtuq8PaQBpwtH6nT3qTaynuYNPbZ+rzaxnYhzICK9RjQk4DYoGANE5qf3kH8= ; Received: from unknown (HELO jupiter.jannicash.info) (janwieck@68.34.254.79 with login) by smtp116.plus.mail.re1.yahoo.com with SMTP; 5 Jul 2007 20:43:46 -0000 X-YMail-OSG: Ip7sBggVM1kSJ4KsA39MmlR68ojt2RFOFWq0FdDVlGepLbTtWfcLjmBbwQIIAvXefIjH81cD_g-- Received: from [172.21.8.128] (mars.jannicash.info [192.168.192.101]) (authenticated bits=0) by jupiter.jannicash.info (8.12.10/8.12.9) with ESMTP id l65KhaHY003705; Thu, 5 Jul 2007 16:43:41 -0400 (EDT) (envelope-from JanWieck@Yahoo.com) Message-ID: <468D57F3.7030405@Yahoo.com> Date: Thu, 05 Jul 2007 16:43:31 -0400 From: Jan Wieck User-Agent: Thunderbird 1.5.0.12 (Windows/20070509) MIME-Version: 1.0 To: Tom Lane CC: PostgreSQL Development Subject: Re: usleep feature for pgbench References: <468D42B3.4010701@Yahoo.com> <20905.1183664046@sss.pgh.pa.us> In-Reply-To: <20905.1183664046@sss.pgh.pa.us> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0.637 tagged_above=0 required=5 tests=AWL=-0.254, BAYES_00=-2.599, DNS_FROM_RFC_ABUSE=0.2, DNS_FROM_RFC_POST=1.708, DNS_FROM_RFC_WHOIS=1.447, FORGED_RCVD_HELO=0.135 X-Spam-Level: X-Archive-Number: 200707/144 X-Sequence-Number: 105059 On 7/5/2007 3:34 PM, Tom Lane wrote: > Jan Wieck 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 #