Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1krXEK-00024x-JO for pgsql-hackers@arkaria.postgresql.org; Tue, 22 Dec 2020 02:16:52 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1krXEI-0003et-PD for pgsql-hackers@arkaria.postgresql.org; Tue, 22 Dec 2020 02:16:50 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1krXEI-0003em-Ie for pgsql-hackers@lists.postgresql.org; Tue, 22 Dec 2020 02:16:50 +0000 Received: from oss.nttdata.com ([49.212.34.109]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1krXEF-0003RN-S9 for pgsql-hackers@postgresql.org; Tue, 22 Dec 2020 02:16:49 +0000 Received: from oss.nttdata.com (localhost [127.0.0.1]) by oss.nttdata.com (Postfix) with ESMTP id BF497600E3; Tue, 22 Dec 2020 11:16:43 +0900 (JST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.102.3 at oss.nttdata.com MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit Date: Tue, 22 Dec 2020 11:16:43 +0900 From: Masahiro Ikeda To: Andres Freund Cc: Fujii Masao , pgsql-hackers Subject: Re: Add statistics to pg_stat_wal view for wal related parameter tuning In-Reply-To: <20201222003935.47aoxfmokltlrlf2@alap3.anarazel.de> References: <11e81f0b7d90dd69077d3d964a9a4da9@oss.nttdata.com> <79620b5c-ecf1-3d4f-80b5-7e311b7a0662@oss.nttdata.com> <89de5056627ebdd144967959bd789bd6@oss.nttdata.com> <58ccc451-8429-ce44-f0b7-773c8dfedf45@oss.nttdata.com> <7eb4ebd487b53200bde98ba2f0a7e789@oss.nttdata.com> <451365b7-9e22-211e-428f-fc90ebc715bc@oss.nttdata.com> <20201221211650.k7b53tcnadrciqjo@alap3.anarazel.de> <20201222003935.47aoxfmokltlrlf2@alap3.anarazel.de> Message-ID: X-Sender: ikedamsh@oss.nttdata.com User-Agent: Roundcube Webmail/1.1.9 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Thanks for your comments. On 2020-12-22 09:39, Andres Freund wrote: > Hi, > > On 2020-12-21 13:16:50 -0800, Andres Freund wrote: >> On 2020-12-02 13:52:43 +0900, Fujii Masao wrote: >> > Pushed. Thanks! >> >> Why are wal_records/fpi long, instead of uint64? >> long wal_records; /* # of WAL records produced */ >> long wal_fpi; /* # of WAL full page images produced */ >> uint64 wal_bytes; /* size of WAL records produced */ >> >> long is only 4 byte e.g. on windows, and it is entirely possible to >> wrap >> a 4 byte record counter. It's also somewhat weird that wal_bytes is >> unsigned, but the others are signed? >> >> This is made doubly weird because on the SQL level you chose to make >> wal_records, wal_fpi bigint. And wal_bytes numeric? I'm sorry I don't know the reason. The following thread is related to the patch and the type of wal_bytes is changed from long to uint64 because XLogRecPtr is uint64. https://www.postgresql.org/message-id/flat/20200402144438.GF64485%40nol#1f0127c98df430104c63426fdc285c20 I assumed that the reason why the type of wal_records/fpi is long is BufferUsage have the members (i.e, shared_blks_hit) of the same types. So, I think it's better if to change the type of wal_records/fpi from long to uint64, to change the types of BufferUsage's members too. > Some more things: > - There's both PgStat_MsgWal WalStats; and static PgStat_WalStats > walStats; > that seems *WAY* too confusing. And the former imo shouldn't be > global. Sorry for the confusing name. I referenced the following variable name. static PgStat_MsgSLRU SLRUStats[SLRU_NUM_ELEMENTS]; static PgStat_SLRUStats slruStats[SLRU_NUM_ELEMENTS]; How about to change from "PgStat_MsgWal WalStats" to "PgStat_MsgWal MsgWalStats"? Is it better to change the following name too? "PgStat_MsgBgWriter BgWriterStats;" "static PgStat_MsgSLRU SLRUStats[SLRU_NUM_ELEMENTS];" Since PgStat_MsgWal is called in xlog.c and pgstat.c, I thought it's should be global. > - AdvanceXLInsertBuffer() does WalStats.m_wal_buffers_full, but as far > as I can tell there's nothing actually sending that? IIUC, when pgstat_send_wal() is called by backends and so on, it is sent to the statistic collector and it is exposed via pg_stat_wal view. Regards, -- Masahiro Ikeda NTT DATA CORPORATION