Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.92) (envelope-from ) id 1j81Ao-0002H9-6Z for pgsql-hackers@arkaria.postgresql.org; Sat, 29 Feb 2020 12:24:50 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1j81Am-0003Ym-VN for pgsql-hackers@arkaria.postgresql.org; Sat, 29 Feb 2020 12:24:48 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1j81Am-0003Vv-Dg for pgsql-hackers@lists.postgresql.org; Sat, 29 Feb 2020 12:24:48 +0000 Received: from mail-wr1-x443.google.com ([2a00:1450:4864:20::443]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1j81Aj-0000Gv-Df for pgsql-hackers@postgresql.org; Sat, 29 Feb 2020 12:24:47 +0000 Received: by mail-wr1-x443.google.com with SMTP id y17so6539024wrn.6 for ; Sat, 29 Feb 2020 04:24:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=2ndquadrant-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=IUkIPyJC3qhbQz8InyywP6h8Bo2Z++n20QD1W8VbsY0=; b=bCa8VEJZCpaQFiOc/EheXimkT3+4Ypv1RdA8ft+TpH+YVuyaJunARGsaG7QlUQwsID 5LqmN9cPAnq6A7l4rUDwwGvk4eJHmZIhuYEcjPeDR3LXLK705sJ6rmTz4FXuGttjWXHR V9S70xxBUoQ0LVKVexqVpq785HJvVbaluV3ojEeF3u5H0Lek2/wPEzMUQbbD6NOW8CQY WboKymqMMw4TbiU/MXdRFECs1ic0e4Ze/zdJWwa82qHagEX37yEb8tUI064vBZZYge6W ngYU0sXe6y0vtugRO158+1GqGYApNTEeSMaaFlEPjcuvnya7SfV0ZG7OjU6aDYQ1DFSp lbvQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=IUkIPyJC3qhbQz8InyywP6h8Bo2Z++n20QD1W8VbsY0=; b=YFgS2vO+mBzhN/mHl62iDv2iz9Z+Re3APhVljpg7Gy9LpSHeglG++YlLec+5HcD/Ho bN+DptvbhXAH3hpMByzSU+ZPShjJeR4O5Sb6veVZvRIBgqdsDzdzkdb7BV/LN7qP5gtJ urKFY0/s9vOo+HWcafMjSw7+F7D4x4d9khew5xFE1gUKHSUudlWM0rcvNR3oJwfqU0jA rlguvo1VWizfQ4Q7XLvBHRwHFupVkB+b3RU0oUopGZIp8enHOXTv2dXfugRMwB43r7kz XV3uTAt0adSvQObhIx/fGmCt7345zgtQULJNdt1pLeOsXXeov4VbNsxZeTDB482ZWAhe qk/w== X-Gm-Message-State: APjAAAXUofWVi37yT65qJbWpUKV1XYKTn90jU9ODG6BfCoN2PrnNTGTz +Y2N5cHfhS6n4EgcxAnc2w1N+w== X-Google-Smtp-Source: APXvYqzpYsOzON5SetDpNt8BISwidvpRkz7D0RC/VjOoYV2zEGTkG7Q02GyJ5ngglTiSaDR52DlXig== X-Received: by 2002:a5d:5044:: with SMTP id h4mr10028413wrt.4.1582979083688; Sat, 29 Feb 2020 04:24:43 -0800 (PST) Received: from localhost (ip-86-49-253-92.net.upcbroadband.cz. [86.49.253.92]) by smtp.gmail.com with ESMTPSA id b186sm6327687wmb.40.2020.02.29.04.24.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 29 Feb 2020 04:24:42 -0800 (PST) Date: Sat, 29 Feb 2020 13:24:41 +0100 From: Tomas Vondra To: Alvaro Herrera Cc: Masahiko Sawada , "tsunakawa.takay@fujitsu.com" , "pgsql-hackers@postgresql.org" Subject: Re: SLRU statistics Message-ID: <20200229122441.ow7gnnqgesmojyc3@development> References: <20200121135614.vt4cpuzwiyarzfca@development> <20200228231918.GA30292@alvherre.pgsql> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline In-Reply-To: <20200228231918.GA30292@alvherre.pgsql> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On Fri, Feb 28, 2020 at 08:19:18PM -0300, Alvaro Herrera wrote: >On 2020-Jan-21, Tomas Vondra wrote: > >> On Tue, Jan 21, 2020 at 05:09:33PM +0900, Masahiko Sawada wrote: > >> > I've not tested the performance impact but perhaps we might want to >> > disable these counter by default and controlled by a GUC. And similar >> > to buffer statistics it might be better to inline >> > pgstat_count_slru_page_xxx function for better performance. >> >> Hmmm, yeah. Inlining seems like a good idea, and maybe we should have >> something like track_slru GUC. > >I disagree with adding a GUC. If a performance impact can be measured >let's turn the functions to static inline, as already proposed. My >guess is that pgstat_count_slru_page_hit() is the only candidate for >that; all the other paths involve I/O or lock acquisition or even WAL >generation, so the impact won't be measurable anyhow. We removed >track-enabling GUCs years ago. > Did we actually remove track-enabling GUCs? I think we still have - track_activities - track_counts - track_io_timing - track_functions But maybe I'm missing something? That being said, I'm not sure we need to add a GUC. I'll do some measurements and we'll see. Maybe the statis inline will me enough. >BTW, this comment: > /* update the stats counter of pages found in shared buffers */ > >is not strictly true, because we don't use what we normally call "shared >buffers" for SLRUs. > Oh, right. Will fix. >Patch applies cleanly. I suggest to move the page_miss() call until >after SlruRecentlyUsed(), for consistency with the other case. > OK. >I find SlruType pretty odd, and the accompanying "if" list in >pg_stat_get_slru() correspondingly so. Would it be possible to have >each SLRU enumerate itself somehow? Maybe add the name in SlruCtlData >and query that, somehow. (I don't think we have an array of SlruCtlData >anywhere though, so this might be a useless idea.) > Well, maybe. We could have a system to register SLRUs dynamically, but the trick here is that by having a fixed predefined number of SLRUs simplifies serialization in pgstat.c and so on. I don't think the "if" branches in pg_stat_get_slru() are particularly ugly, but maybe we could replace the enum with a registry of structs, something like rmgrlist.h. It seems like an overkill to me, though. regards -- Tomas Vondra http://www.2ndQuadrant.com PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services