Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1sljGA-000pX1-Jh for pgsql-hackers@arkaria.postgresql.org; Wed, 04 Sep 2024 06:12:55 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1sljG9-004xid-0c for pgsql-hackers@arkaria.postgresql.org; Wed, 04 Sep 2024 06:12:53 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1sljG8-004xi1-NE for pgsql-hackers@lists.postgresql.org; Wed, 04 Sep 2024 06:12:53 +0000 Received: from fout8-smtp.messagingengine.com ([103.168.172.151]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1sljG6-0004A2-EO for pgsql-hackers@lists.postgresql.org; Wed, 04 Sep 2024 06:12:51 +0000 Received: from phl-compute-07.internal (phl-compute-07.phl.internal [10.202.2.47]) by mailfout.phl.internal (Postfix) with ESMTP id 6DB3C13801E0; Wed, 4 Sep 2024 02:12:49 -0400 (EDT) Received: from phl-mailfrontend-02 ([10.202.2.163]) by phl-compute-07.internal (MEProxy); Wed, 04 Sep 2024 02:12:49 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paquier.xyz; h= cc:cc:content-type:content-type:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:subject :subject:to:to; s=fm1; t=1725430369; x=1725516769; bh=wnh2JUKY8r +N4Ac7abK0yUhVDTwlfgNXOzkYI0Jkr9E=; b=iGFFuF0kCKLuBKLfi/jgellYLK LGkpY7Gh9arzZw2pGgfWwicj6wMZabMMHpmLpTNYfJwUHhY4s77WPC/lcsMFv4ke IjAgdC+hcIruDNFD2FeK9jighvW0/MaXpoLcm5rf+JAsI2vhVETC1bzkWOQKZNrl b/Otdcv5o6Ug67cpl3ozP+MGO5Q2Hv26b45L4itk9+xJ7X8yoA7/SmlZn6j/JYQF zHycjHxOm+5LBr3a792+kClXQq88kL9OjR3ois9PIgITDOlWxWCkLwEGV+AKQ6Q5 EVbuxOkzAjRVMXRozS1QVCY1VwQW41qGW1iHilEdC5FSXfIQTnMPSXQ/RRSw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:content-type:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:subject:subject:to :to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm1; t=1725430369; x=1725516769; bh=wnh2JUKY8r+N4Ac7abK0yUhVDTwl fgNXOzkYI0Jkr9E=; b=HrMN7Lr5PrPuVhVcshX60IT9zz8DzbckXVcF82nsOVLa p2sV0EyD3x9NgWvouCuco6GsC0LEIpXAJOBo8p8z1MGH4JL47zcoIbxNNDVIMh4U BUA55CUYX0VyIBNcl986+jhJhR0m6iPDND1bgiAoaqSK6adtKDmqXgZQhsfU6dDF +HEpcqBmmUYn/vt639tUFd71rX1MivOMcZzbdyf2JfwBu5ZxkxMX0c/TOI/vwMVt ARCygyB51NXD0W8+bOMLI14jU0vJ8g8DxV56yvezdHClz8E3xuPXxzZAv7Vi78xW fjvNr82mcP98UrFu5SyfETAEvJtBChZDNF2T+gUaCA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeftddrudehiedguddtfecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpggftfghnshhusghstghrihgsvgdp uffrtefokffrpgfnqfghnecuuegrihhlohhuthemuceftddtnecufghrlhcuvffnffculd ejtddmnecujfgurhepfffhvfevuffkfhggtggujgesghdtreertddtvdenucfhrhhomhep ofhitghhrggvlhcurfgrqhhuihgvrhcuoehmihgthhgrvghlsehprghquhhivghrrdighi iiqeenucggtffrrghtthgvrhhnpeetleeifedufffhhfdtteelgeeggeffhfekueevteei gfduudevudetgfegiedvjeenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmh grihhlfhhrohhmpehmihgthhgrvghlsehprghquhhivghrrdighiiipdhnsggprhgtphht thhopeefpdhmohguvgepshhmthhpohhuthdprhgtphhtthhopegsvghrthhrrghnuggurh houhhvohhtrdhpghesghhmrghilhdrtghomhdprhgtphhtthhopehhohhrihhkhihothgr rdhnthhtsehgmhgrihhlrdgtohhmpdhrtghpthhtohepphhgshhqlhdqhhgrtghkvghrsh eslhhishhtshdrphhoshhtghhrvghsqhhlrdhorhhg X-ME-Proxy: Feedback-ID: i0fe9450f:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 4 Sep 2024 02:12:47 -0400 (EDT) Date: Wed, 4 Sep 2024 15:12:37 +0900 From: Michael Paquier To: Bertrand Drouvot Cc: Kyotaro Horiguchi , pgsql-hackers@lists.postgresql.org Subject: Re: Add callbacks for fixed-numbered stats flush in pgstats Message-ID: References: <20240904.140546.948122275033564187.horikyota.ntt@gmail.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="4uTjVnhHU7HVKh+5" Content-Disposition: inline In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --4uTjVnhHU7HVKh+5 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Wed, Sep 04, 2024 at 05:28:56AM +0000, Bertrand Drouvot wrote: > On Wed, Sep 04, 2024 at 02:05:46PM +0900, Kyotaro Horiguchi wrote: >> The generalization sounds good to me, and hiding the private flags in >> private places also seems good. >=20 > +1 on the idea. Thanks for the feedback. >> Regarding pgstat_io_flush_cb, I think it no longer needs to check the >> have_iostats variable, and that check should be moved to the new >> pgstat_flush_io(). The same applies to pgstat_wal_flush_cb() (and >> pgstat_flush_wal()). As for pgstat_slru_flush_cb, it simply doesn't >> need the check anymore. >=20 > Agree. Another option could be to add only one callback (the flush_fixed_= cb one) > and get rid of the have_fixed_pending_cb one. Then add an extra parameter= to the > flush_fixed_cb that would only check if there is pending stats (without > flushing them). I think those 2 callbacks are highly related that's why I= =20 > think we could "merge" them, thoughts? I would still value the shortcut that we can use if there is no activity to avoid the clock check with GetCurrentTimestamp(), though, which is why I'd rather stick with two callbacks as that can lead to a much cheaper path. Anyway, I am not sure to follow your point about removing the boolean checks in the flush callbacks. It's surely always a better to never call LWLockAcquire() or LWLockConditionalAcquire() if we don't have to, and we would go through the whole flush dance as long as we detect some stats activity in at least one stats kind. I mean, that's cheap enough to keep around. -- Michael --4uTjVnhHU7HVKh+5 Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEEG72nH6vTowiyblFKnvQgOdbyQH0FAmbX+lUACgkQnvQgOdby QH1Jqg/+JRoJ8U1mn7Iclf4LV7vOsxQAhBBqMgJsp0YWPQG3acNzn+9tar8rSRhc g763kFEuEtSBbTxLZqvYGwbyFoWkRaUBFEul6HHaLsWqJJ4sBEcFYPqZs4HTBIF8 +AQSPhSS1mJUvPYJLH2zJ0B7rB0mRgcA+69SAbEAFwbt+euWuxzSTSV9GcizL3F3 P3c2d56CTqNVO+VsV01nS5Tq9rayL/fg9Cw1WClRFSFsDCHKlNMJ+a+/llK37hKS 9/fhf1wpOQmD/GmDY93lfLPPbNbxGjyYbkR+V7YDIQFgBxH1J80Yjnj1KJ6PjJfN L7lECEMT2CvSfJdYkVX4lBaFwg7bEcWolA37bHiWjzHMMNksmJIjOA5FT66PRFvU tnVL+o0PH9IxCRp0Gdbz31JWLFtMig6dd7SYSNMkHUM5Ux1l0MYlAb7QnXuwgCK7 WSRUN2YpiFpF05PKJp+MS9pZ6VnOTlkg+Y87MUVlB4KSBBjDspqcF9t8rX/wT3kZ cNFcJHfubBQpmi7ZgdZpx23W1UCOrQDoRKbLcmPKBKBnwz6XFm14QkFTvj1O7dtq fb6GFmkvA7vCRk78q6hOiueZ1A0Yqq5crs+regDGHpKMpEqUH0C3jqCiI95VXRW9 tq9n7VvgR2pMmtwOqWm7MxGtrxwGmMLjhC6xXuVGI7Q7lyr8FJg= =GJbW -----END PGP SIGNATURE----- --4uTjVnhHU7HVKh+5--