Received: from maia.hub.org (unknown [200.46.204.183]) by mail.postgresql.org (Postfix) with ESMTP id 8BDC8633648 for ; Wed, 17 Feb 2010 16:01:16 -0400 (AST) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 54116-02 for ; Wed, 17 Feb 2010 20:01:05 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from outbound.afilias.info (outbound.afilias.info [69.46.124.26]) by mail.postgresql.org (Postfix) with ESMTP id 508E56421C4 for ; Wed, 17 Feb 2010 15:01:18 -0400 (AST) Received: from ms5.yyz2.afilias-ops.info ([10.50.129.111] helo=smtp.afilias.info) by outbound.afilias.info with esmtp (Exim 4.69) (envelope-from ) id 1Nhp9A-00025s-5b; Wed, 17 Feb 2010 19:01:16 +0000 Received: from tor-gateway.afilias.info ([199.15.87.4] helo=[10.10.46.12]) by smtp.afilias.info with esmtpsa (SSLv3:AES256-SHA:256) (Exim 4.69) (envelope-from ) id 1Nhp9A-0001j1-58; Wed, 17 Feb 2010 19:01:16 +0000 Subject: Re: bgwriter tunables vs pg_stat_bgwriter From: Brad Nicholson To: Jeff Cc: pgsql-performance@postgresql.org In-Reply-To: <777025E3-813C-4EA6-B654-E4C54F83AA1A@torgo.978.org> References: <777025E3-813C-4EA6-B654-E4C54F83AA1A@torgo.978.org> Content-Type: text/plain Date: Wed, 17 Feb 2010 14:01:16 -0500 Message-Id: <1266433276.4412.39.camel@bnicholson-desktop> Mime-Version: 1.0 X-Mailer: Evolution 2.26.1 Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-0.185 tagged_above=-10 required=5 tests=BAYES_40=-0.185 X-Spam-Level: X-Archive-Number: 201002/267 X-Sequence-Number: 37688 On Wed, 2010-02-17 at 08:30 -0500, Jeff wrote: > Since getting on 8.4 I've been monitoring things fairly closely. > I whipped up a quick script to monitor pg_stat_bgwriter and save > deltas every minute so I can ensure my bgwriter is beating out the > backends for writes (as it is supposed to do). > > Now, the odd thing I'm running into is this: > > bgwriter_delay is 100ms (ie 10 times a second, give or take) > bgwriter_lru_maxpages is 500 (~5000 pages / second) > bgwriter_lru_multiplier is 4 > > Now, assuming I understand these values right the following is what > should typically happen: > > while(true) > { > if buffers_written > bgwriter_lru_maxpages > or buffers_written > anticipated_pages_needed * > bgwriter_lru_multiplier > { > sleep(bgwriter_delay ms) > continue; > } > ... > } Correct. > so I should not be able to have more than ~5000 bgwriter_clean pages > per minute. (this assumes writing takes 0ms, which of course is > inaccurate) That works out to 5000/second - 300,000/minute. > However, I see this in my stats (they are deltas), and I'm reasonably > sure it is not a bug in the code: > > (timestamp, buffers clean, buffers_checkpoint, buffers backend) > 2010-02-17 08:23:51.184018 | 1 | 1686 > | 5 > 2010-02-17 08:22:51.170863 | 15289 | 12676 > | 207 > 2010-02-17 08:21:51.155793 | 38467 | 8993 > | 4277 > 2010-02-17 08:20:51.139199 | 35582 | 0 > | 9437 > 2010-02-17 08:19:51.125025 | 8 | 0 > | 3 > 2010-02-17 08:18:51.111184 | 1140 | 1464 > | 6 > 2010-02-17 08:17:51.098422 | 0 | 1682 > | 228 > 2010-02-17 08:16:51.082804 | 50 | 0 > | 6 > 2010-02-17 08:15:51.067886 | 789 | 0 > | 1 > > perhaps some stats buffering occurring or something or some general > misunderstanding of some of these tunables? > > -- > Jeff Trout > http://www.stuarthamm.net/ > http://www.dellsmartexitin.com/ > > > > -- Brad Nicholson 416-673-4106 Database Administrator, Afilias Canada Corp.