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.96) (envelope-from ) id 1w4aUJ-002LAk-0p for pgsql-hackers@arkaria.postgresql.org; Mon, 23 Mar 2026 08:18:15 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1w4aUG-00GO1s-25 for pgsql-hackers@arkaria.postgresql.org; Mon, 23 Mar 2026 08:18:13 +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.96) (envelope-from ) id 1w4aUG-00GO1j-17 for pgsql-hackers@lists.postgresql.org; Mon, 23 Mar 2026 08:18:12 +0000 Received: from mail-wm1-x335.google.com ([2a00:1450:4864:20::335]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1w4aUD-00000000dSY-2olQ for pgsql-hackers@lists.postgresql.org; Mon, 23 Mar 2026 08:18:12 +0000 Received: by mail-wm1-x335.google.com with SMTP id 5b1f17b1804b1-48374014a77so37801085e9.3 for ; Mon, 23 Mar 2026 01:18:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1774253888; x=1774858688; darn=lists.postgresql.org; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date:from:to :cc:subject:date:message-id:reply-to; bh=cp2exvzMWqafO/6owoxLLhdIQUdvtRa/Gsd+z5T73CE=; b=iXmcW2K5UZLmbR8AUWIos5aqBnpumfowJahNrg0epn8EBZeoePbVoiWC2r7PNE9QAX GtR5UGrIyqMal/uBfv+jQv1ve3rykKKFkunGQ5g7Yz/kMNukeXCXhx0tCXvZNpYH/9S1 vD9jfVyyShQliKQ/+rV18pDFZvNMJlXhBNa69H/TNKlBz82e+VIdkx3w0ymlMFvZVH3e KyUfCOrR6XhTTcdGu6r6JJF6BGAbnwPUGDVYUG1GZ0VzNgifWg5xRIhuCBoMc2632gQc /7IkvVESoltfq00SYKsYDnlL0EeYc1aQyuvl3+bS2ByUIQFleMxXPKFdbShbIBBVrO2K O8kQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1774253888; x=1774858688; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=cp2exvzMWqafO/6owoxLLhdIQUdvtRa/Gsd+z5T73CE=; b=SlOrMQHIXGFU+/pUbY7IXMDUB8VyQbvfjT9S8JBBdNZm1Mbsjmle2NiBUTm0eyf8Lw JUeV58l0ibOYf3L85k4hbBZOno+/+bR8sc3ODdGu/0e2OMe1j+bv/xr0yYojvRtGipWh EqwKaa7rPbDxTCBFi2UfbzGc7R3zfUjflYcXaPEISQt6E4Vyw5AKUD88hMgRb8x5f8Ux vhCSONgT37YLXuf61AkB9yglkrryW/i/BMSxRJnde3QAq9eCDSl5N8VDtyDEuvYkTKxO zHhKEGpq1qGLWzr0FRGB2CV1UOFjownGN9WDGLg3AjMShJM02hv3r0GeXK4c4/wK3fdn xfjw== X-Forwarded-Encrypted: i=1; AJvYcCWdMo8gmWPHs6xt3g7CJ+ZMkdHycxLmH2Vuo7I+ZkDXoeJJlzasu6upYBmsdCnGgzsI2p+2mppyVIo2X19Z@lists.postgresql.org X-Gm-Message-State: AOJu0Yxt8meDg+daeB1T6Q1Zk/6zAmGFzVXNhUcNdjN0DCIMMgyy3000 EcshwIzFDFEtPhABOsTjRQQzljOupPLkfWCtQI4CSEX3vVJeEyl410+2 X-Gm-Gg: ATEYQzzCvDqMozuP3R5s8fH8ohf6+mmn9F5t8j27kphstK9fH/+3T1ZVm0FI/hSDxmK qeY1YSioIB0dnWe4/DouFnaoJxFKobU7Bnc3nsCC4B9zareA9qvzOjAFNaKcvnUZ7izeBujIKbf DwCMez2GHAIAJTX0bGC/IH5jQkVkHLYDv4hz8XCErzsUCj3LcPp3uk99rJfcBTm8/qd61pojFN/ Ubad5Y+LOdxLyAjQLj4y+K4Ukja+1Cz9uscGrk4mskdOYbpjyfZSiyfdHyj6UVcbcgJ8LIq3iUk bFfvAcfMG/zfvAHK1aRtgOT+ecAQGNF3Hi9RNYQzdRmFU0kbwq9M3pcn5LBUzJjOyucP1BvXmHj satzQK1yXCEKUoQBiT0NnLPcG9tdSykiS9Mb9rF2AOya8TgxiVcxohPUQi+nnttmLjZj5kOYxsc f8mHh9xlH+dKBINvlf3ayKaYs6RhGyBKyGpwZ8X57+9XY5n1Q5EmEcRrmirQT5Hd+MlrJkFy+0b xjrvOAWXVVoWUj2ygMsIq565XCBCekrD4gMk+fnr/hTXTPPCj/skrHW2g== X-Received: by 2002:a05:600c:8b31:b0:485:40a4:364 with SMTP id 5b1f17b1804b1-486fee1af50mr156105115e9.26.1774253887407; Mon, 23 Mar 2026 01:18:07 -0700 (PDT) Received: from ip-10-97-1-34.eu-west-3.compute.internal (ec2-15-237-197-144.eu-west-3.compute.amazonaws.com. [15.237.197.144]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-43b644bf1c5sm29987071f8f.14.2026.03.23.01.18.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Mar 2026 01:18:06 -0700 (PDT) Date: Mon, 23 Mar 2026 08:18:05 +0000 From: Bertrand Drouvot To: =?iso-8859-1?Q?=C1lvaro?= Herrera Cc: Michael Paquier , Andres Freund , Jeff Davis , Greg Sabino Mullane , "L. pgsql-hackers" Subject: Re: Adding locks statistics Message-ID: References: <202603221856.iwlhitt6dxxx@alvherre.pgsql> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <202603221856.iwlhitt6dxxx@alvherre.pgsql> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Hi, On Sun, Mar 22, 2026 at 08:37:47PM +0100, Álvaro Herrera wrote: > On 2026-Mar-21, Álvaro Herrera wrote: > > > I checked this, and found a couple of headers that can benefit from a > > removal, as shown in the attached patches. > > I looked again and found some more; the first 14 patches attached here > do so. A couple of them have no fallout to speak of, which I find > really surprising; for the majority we just need a couple of extra > includes somewhere or a typedef or two. I unleashed CI on it to see > what would happen, > https://cirrus-ci.com/build/5522804717649920 Thanks for looking at it! I looked at the C files changes that now need to include lock.h (or other ones) directly: verify_heapam.c: lock.h was indirectly included through procarray.h heapam_handler.c: lock.h was indirectly included through heapam.h -> tableam.h -> vacuum.h relation.c: lock.h was indirectly included through namespace.h reloptions.c: lock.h was indirectly included through reloptions.h indexam.c: lock.h was indirectly included through reloptions.h relcache.c: lock.h was indirectly included through reloptions.h syscache.c: lock.h was indirectly included through lmgr.h discard.c: lock.h was indirectly included through namespace.h pg_subscription.c: lock.h was indirectly included through heapam.h -> tableam.h -> vacuum.h nbtree.c: lock.h was indirectly included through vacuum.h nbtutils.c: lock.h was indirectly included through reloptions.h pg_inherits.c: lock.h was indirectly included through pg_inherits.h inherit.c: lock.h was indirectly included through pg_inherits.h conversioncmds.c: lock.h was indirectly included parse_func.h -> namespace.h tablespace.c: lock.h was indirectly included through heapam.h -> tableam.h -> vacuum.h parse_oper.c: lock.h was indirectly included through parse_func.h -> namespace.h sequencesync.c: lock.h was indirectly included through worker_internal.h ts_cache.c: lock.h was indirectly included through namespace.h So the changes done in your patches make sense to me. I have 2 comments: 1/ wait_event.c -#include "storage/lmgr.h" /* for GetLockNameFromTagType */ -#include "storage/lwlock.h" /* for GetLWLockIdentifier */ +#include "storage/lmgr.h" +#include "storage/lwlock.h" +#include "storage/shmem.h" #include "storage/spin.h" +#include "utils/hsearch.h" hsearch.h is already included into shmem.h so its direct include is not needed. That said wait_event.c needs it so including it directly might make sense just from a coding "style" point of view (given that it is harmless as it is protected by ifndef HSEARCH_H). 2/ Not directly linked to your patches It looks like that aio_funcs.c does not need lock.h (reported by include-what-you-use). If we remove its direct include, it's still indirectly included through proc.h though. But I think that removing its direct include makes sense as it's not needed at all. If we still need to discuss about those lock.h related changes, maybe it's worth creating a dedicated thread? Regards, -- Bertrand Drouvot PostgreSQL Contributors Team RDS Open Source Databases Amazon Web Services: https://aws.amazon.com