Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1Xtl2p-0002nD-Pq for pgsql-bugs@arkaria.postgresql.org; Wed, 26 Nov 2014 22:26:43 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1Xtl2p-0008Jm-9A for pgsql-bugs@arkaria.postgresql.org; Wed, 26 Nov 2014 22:26:43 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1Xtl2n-0008H3-K1 for pgsql-bugs@postgresql.org; Wed, 26 Nov 2014 22:26:41 +0000 Received: from smtp-out2.gransy.com ([77.78.126.49]) by makus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1Xtl2j-0006Yg-S4 for pgsql-bugs@postgresql.org; Wed, 26 Nov 2014 22:26:39 +0000 Received: from smtp-out.gransy.com (localhost [127.0.0.1]) by smtp-out2.gransy.com (Postfix) with ESMTP id 344E63F0133 for ; Wed, 26 Nov 2014 23:26:39 +0100 (CET) Received: from smtp.gransy.com (smtp.simplia.cz [77.78.126.20]) by smtp-out2.gransy.com (Postfix) with ESMTP id C41393F0120 for ; Wed, 26 Nov 2014 23:26:38 +0100 (CET) Received: from [192.168.1.163] (ip-78-45-139-138.net.upcbroadband.cz [78.45.139.138]) (Authenticated sender: tv@fuzzy.cz) by smtp.gransy.com (Postfix) with ESMTPSA id 8DADF19A0456 for ; Wed, 26 Nov 2014 23:26:29 +0100 (CET) Message-ID: <5476539A.6090506@fuzzy.cz> Date: Wed, 26 Nov 2014 23:26:34 +0100 From: Tomas Vondra User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.2.0 MIME-Version: 1.0 To: pgsql-bugs@postgresql.org Subject: Re: BUG #12071: Stat collector went crasy (50MB/s constant writes) References: <20141126130810.15507.39189@wrigleys.postgresql.org> <54763BD8.8020906@fuzzy.cz> <54764BF6.20605@fuzzy.cz> In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Pg-Spam-Score: -1.9 (-) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-bugs Precedence: bulk Sender: pgsql-bugs-owner@postgresql.org On 26.11.2014 23:06, Maxim Boguk wrote: > > > I'm not sure I understand what you mean. > > The timestamp *IS* updated on every write - see this: > > https://github.com/postgres/postgres/blob/REL9_2_STABLE/src/backend/postmaster/pgstat.c#L3469 > > > I mean that usually 99.9% writes goes through mmap, which update the > pgstat.tmp file timestamp (but not update last_statwrite value). I don't follow. Can you explain what you mean by the mmap? I don't see any mmap stuff in pgstat.c, nor I remember dealing with mmap in my patches in this area ... You mentioned the snippet: if (last_statwrite < last_statrequest) pgstat_write_statsfile(false); and essentially what pgstat_write_statsfile() does is this: 1) open pgstat.tmp file 2) update globalStats.stats_timestamp to GetCurrentTimestamp(); 3) write globalStats to the new file 4) ... so it *does* update the timestamp on each write. > But that enough to make backend_read_statsfile happy around > https://github.com/postgres/postgres/blob/REL9_2_STABLE/src/backend/postmaster/pgstat.c#L3972 > without kicking poor statistic collector (and forcing full file rewrite) at > https://github.com/postgres/postgres/blob/REL9_2_STABLE/src/backend/postmaster/pgstat.c#L3978 Well, the thing is that with 10 databases and 1s naptime, the launcher starts a new autovacuum process every 100 ms. The first thing every worker does is pgstat_read_statsfile() and this checks whether the stats are older than 10 ms (which it is, because the last worker started ~100ms ago), and sends a new inquiry. Regular backends use 640ms threshold, which is less than 100ms. > PS: 1second autovacuum_naptime could be useful if you have small but > very very actively updated tables, over 1 minute they could growth > 100-500x size without autovacuum. > 1minute naptime will have the same issue with 500 small idle databases :). True. That's why I have reworked this in 9.3. Anyway, this is not a bug - it works as designed/expected. It may be imperfect, but that's how it is. The only thing you can do in 9.2 is moving the pgstat.tmp to a tmpfs filesystem Tomas -- Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs