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 1oLkQT-00034C-48 for pgsql-hackers@arkaria.postgresql.org; Wed, 10 Aug 2022 12:03:05 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1oLkQQ-0001aa-Ho for pgsql-hackers@arkaria.postgresql.org; Wed, 10 Aug 2022 12:03:02 +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 1oLkQQ-0001ZY-1V for pgsql-hackers@lists.postgresql.org; Wed, 10 Aug 2022 12:03:02 +0000 Received: from smtp-fw-6002.amazon.com ([52.95.49.90]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oLkQJ-0000pZ-Vb for pgsql-hackers@lists.postgresql.org; Wed, 10 Aug 2022 12:03:00 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazon201209; t=1660132976; x=1691668976; h=message-id:date:mime-version:subject:to:cc:references: from:in-reply-to:content-transfer-encoding; bh=qhu4omWH/OlIG2AAcLC1kzZnD25HCZ4L2dB2jyCjGoY=; b=oQpc+ddY+9dKWReaKYChuqsWXVHwgPIREyOSVRBi8BlhWVPKM7/Qc3B8 r3dTGBwMRT1Uy7w2Xv6aKrEuhKn29XOEjAnT4foHxEbeGQjz2YAnDyLuf fIg+vVzgVPJJFcEu8yJ3CWyWX+YP3wNrNLpc5fdGuyKvfeUmxffG0U0l5 Q=; X-IronPort-AV: E=Sophos;i="5.93,227,1654560000"; d="scan'208";a="231395013" Received: from iad12-co-svc-p1-lb1-vlan3.amazon.com (HELO email-inbound-relay-pdx-2c-4213ea4c.us-west-2.amazon.com) ([10.43.8.6]) by smtp-border-fw-6002.iad6.amazon.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Aug 2022 12:02:43 +0000 Received: from EX13D03EUC003.ant.amazon.com (pdx1-ws-svc-p6-lb9-vlan3.pdx.amazon.com [10.236.137.198]) by email-inbound-relay-pdx-2c-4213ea4c.us-west-2.amazon.com (Postfix) with ESMTPS id 8E66C812AE; Wed, 10 Aug 2022 12:02:41 +0000 (UTC) Received: from [192.168.10.191] (10.43.162.227) by EX13D03EUC003.ant.amazon.com (10.43.164.192) with Microsoft SMTP Server (TLS) id 15.0.1497.36; Wed, 10 Aug 2022 12:02:38 +0000 Message-ID: <3d853c6f-445f-782e-eab0-525729952d4c@amazon.com> Date: Wed, 10 Aug 2022 14:02:34 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0) Gecko/20100101 Thunderbird/102.1.1 Subject: Re: shared-memory based stats collector - v70 Content-Language: en-US To: Kyotaro Horiguchi , CC: , References: <20220809.172435.775392169163486535.horikyota.ntt@gmail.com> <20220809165319.jdzd225xohqf6o57@awork3.anarazel.de> <20220810.113910.92411510444435201.horikyota.ntt@gmail.com> From: "Drouvot, Bertrand" In-Reply-To: <20220810.113910.92411510444435201.horikyota.ntt@gmail.com> Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 8bit X-Originating-IP: [10.43.162.227] X-ClientProxiedBy: EX13D06UWA001.ant.amazon.com (10.43.160.220) To EX13D03EUC003.ant.amazon.com (10.43.164.192) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Hi, On 8/10/22 4:39 AM, Kyotaro Horiguchi wrote: > At Tue, 9 Aug 2022 09:53:19 -0700, Andres Freund wrote in >> Could you try the pgstat_lock_entry_shared() approach? > Of course. Please find the attached. Thanks for the patch! It looks good to me. One nit comment though, instead of: +               /* +                * Take lwlock directly instead of using pg_stat_lock_entry_shared() +                * which requires a reference. +                */ what about? +               /* +                * Acquire the LWLock directly instead of using pg_stat_lock_entry_shared() +                * which requires a reference. +                */ I think that's more consistent with other comments mentioning LWLock acquisition. Regards, -- Bertrand Drouvot Amazon Web Services: https://aws.amazon.com