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 1uqeND-00AQvZ-Lp for pgsql-hackers@arkaria.postgresql.org; Mon, 25 Aug 2025 21:05:05 +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 1uqeNC-00EIsk-Qj for pgsql-hackers@arkaria.postgresql.org; Mon, 25 Aug 2025 21:05:03 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1uqeNC-00EIsc-Gu for pgsql-hackers@lists.postgresql.org; Mon, 25 Aug 2025 21:05:03 +0000 Received: from mail-io1-xd31.google.com ([2607:f8b0:4864:20::d31]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1uqeNA-001pf2-35 for pgsql-hackers@postgresql.org; Mon, 25 Aug 2025 21:05:02 +0000 Received: by mail-io1-xd31.google.com with SMTP id ca18e2360f4ac-8844ee2cb61so131764939f.2 for ; Mon, 25 Aug 2025 14:05:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1756155899; x=1756760699; darn=postgresql.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=z+HFe9GaDpIMnKCd2WWeNM7pq9wPG3meuA/G5R5ufVE=; b=j/46pLvoTZAmkl80+NbT0pmR9Yd9hVu6a0Lcsv64qfXOb/Dd5YlZyvpxue+wpxAvj2 aVIyEGKYSewednJ80C5dBMAj4DdspmE5ecn8sqxXmxNvLPiMpotkIIneLWbTH86jkrHn km1VoFAmiFuJvdOfJGfMe+bx1P2K+tA/y7d0aOziVMi/o+NW/BKXsJYV1oEYmO031BBN YKiR7VC9ViCCQXacZ7xdAtdLM6DFSY0t5VOBBIFtbi6qCKRfW6N8qQvFRCuWaZNz6n0U 1mDaUrhnCxQZKU16PtK7z4BKmlOnXg33tKCYgneKYo0qwNSdiJ+CtNCqmFv1RifDLXj7 92SQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1756155899; x=1756760699; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=z+HFe9GaDpIMnKCd2WWeNM7pq9wPG3meuA/G5R5ufVE=; b=nEfLSxFkv0ZLd8+epIdObyG/PRMLFR7IYPj2KNVb+FqQnPwy2XXprgUz4DXnatD8W4 YsrGmgpDqDyr/A9PC8NJRWVK4HgxZNRJfVBdy62lfNvFEJNvfDfIJ/Q5SXzN3ryyVpfP F5LxdGa3twM5+m0NZla+OTx8FvuayiCZ7/ou7G2W9xZ7xKhwXtpScufuDNNYWcnIMWR7 g53CwTMFLL2PJjh3pw7p+Iv+5iXUveG99TNN0XkhVR2qCYxq251tyHzLSpUmE1PR4tMG VaCr41gxutCQkrwY7ABGhMmQ7+TesSK4OUbRqqdrsV239l4GoqRYFV/fs/Ot42mEGxYJ CPvg== X-Forwarded-Encrypted: i=1; AJvYcCW1iMabjepI1173SOeoFC26YvMEyBheUMvOo/tVzSYbhRqgtz3JnyZKq57axsVLYzkPBzleYi/5H9Zt5ckL@postgresql.org X-Gm-Message-State: AOJu0YxrFpstYcUgehd1dkobzUFHjItS+J5upolqKS2Nq7HYO1ISMjUq WTjDcoN8fbsYAzT8gr6JBcx5ZXguJh7699MC3vBDHbIEuTpoFnnhrw37 X-Gm-Gg: ASbGncv82vJGqHgQJcH4Lt0wTJgF8KTmKEfb0l5LIcnqVTziwf0Q6uwQIP24fVgQzcN J+oOOZOW/U6+yPB5/+j+gLDLr5AkR4UERtlmyt6rlZG8F/HnF+hZP3vamGIxO2Gi7rSPXnCJqA1 NxJG61ITFHmfcsEJJ9O71rFcoG4S6XkVWkMOBG9dPDfXlR4ceMCQnoLM9ILGkyJKE9nj4hU+gFB /NqK0cw9AHgQo/vbQKyGatvwIfqy9SVP+MKH4JjvqMJRbgsNPxDA3mSd71cdRoO7eBf3O58u9L1 UuIOZ9IbUfRF55wfR1JTQ9MJs6ln3eJlZvHGVd9glJjlPiVEdqwbH/VFtRwn5TpbTbjYEtzGzLn Avcrv9Ry/f68N7+rbMvOPGdYhWFyQx8FVoRY1MvfhBYMXlGiNTw4w5482qpe1+TKCV3kVxAJKcC 6Jxj5Dqc/zUiWe X-Google-Smtp-Source: AGHT+IE9z5+Iv8hVjVpYt9GAdCBR3/a+5VAx9KJUXjx9r1ZhLMCpwoXVKLWTk2hT+gtXbgW2l4+Dqg== X-Received: by 2002:a05:6602:6d1b:b0:881:659f:cd59 with SMTP id ca18e2360f4ac-886bd1313a9mr2328623839f.5.1756155898727; Mon, 25 Aug 2025 14:04:58 -0700 (PDT) Received: from nathan (162-195-168-172.lightspeed.stlsmo.sbcglobal.net. [162.195.168.172]) by smtp.gmail.com with ESMTPSA id ca18e2360f4ac-886d9cad307sm259826639f.3.2025.08.25.14.04.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Aug 2025 14:04:58 -0700 (PDT) Date: Mon, 25 Aug 2025 16:04:56 -0500 From: Nathan Bossart To: Sami Imseih Cc: Tom Lane , Andres Freund , Bertrand Drouvot , Rahila Syed , pgsql-hackers Subject: Re: Improve LWLock tranche name visibility across backends Message-ID: References: <34drxi6kshtzu5aerftjflrm6wfxxw54emyvy4gqemdpxxuhvm@gymw6its72o7> <5to6tftuml6nkas4jaaljfzecasvslxq3mumeslh74wsol4mzw@rgxpxxlqqwtf> <876523.1755635201@sss.pgh.pa.us> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Fri, Aug 22, 2025 at 03:01:53PM -0500, Sami Imseih wrote: > I kept the local array to serve consecutive reads and to avoid having to > take a shared lock on shared memory every time GetLWTrancheName is > called. A new LWLock to protect this array is required. I'm not seeing why we need this cache anymore. This is an append-only list, so we could instead keep a backend-local copy of LWLockCounter that gets updated as needed. As long as the ID is less than our backend-local counter, we can go straight to the shared array. If it is greater, we'll have to first update our counter, which should be rare and inexpensive. -- nathan