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 1wIoMA-008VCY-2K for pgsql-hackers@arkaria.postgresql.org; Fri, 01 May 2026 13:56:39 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1wIoM9-00BI1Y-26 for pgsql-hackers@arkaria.postgresql.org; Fri, 01 May 2026 13:56:37 +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 1wIoM9-00BI1Q-19 for pgsql-hackers@lists.postgresql.org; Fri, 01 May 2026 13:56:37 +0000 Received: from mail-wm1-x330.google.com ([2a00:1450:4864:20::330]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1wIoM7-00000004H4R-1WiW for pgsql-hackers@postgresql.org; Fri, 01 May 2026 13:56:37 +0000 Received: by mail-wm1-x330.google.com with SMTP id 5b1f17b1804b1-483487335c2so21370075e9.2 for ; Fri, 01 May 2026 06:56:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1777643794; x=1778248594; darn=postgresql.org; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=TyIUnBbde1QcETFNgIdeYiXjJi9TErkwP6W5rrmT+eE=; b=cgBE7lkFxnA5GUv6WLWZJJ7up0HRKbfZs3wDvpqDjHFpyicI5u9SZrtCnYmH0nZKck 72GMGI6QFGAmpyHkvJrCK1cuhPMA1pcCB62Nwfl9NCfK+lzoCrnHcQkOczdBXZNbXptX WVT6Bv96QIF7fj93pZNr76c8EYJM+v1mF+o2RTEUbUlKGKMTvhJ+2PQtcYwa5l9qDxOM UlzsQgrds3Fx1kmH6A5wEXLFU4LKobpay/cV/fwRVoHNxtLqPY73YGoT02hVI5XEzlSw bHiEtJQQgeSzIczOO0YnlhVGcGxNoWKfLNWWNyTF32Vgr3V5EGiYMKE96H6VwumGN18H 7GYw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1777643794; x=1778248594; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :x-gm-gg:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=TyIUnBbde1QcETFNgIdeYiXjJi9TErkwP6W5rrmT+eE=; b=KSsddu4ggBNp/yC3VIbAaFhfGJvI4vUQbMJHdB2qM9N0YSZ9uFJFymXGYvZg+qnqBR FmkXurtgOtodOj4kbsT6OAqENaPYK/3dtf/ZdC1IoPDFARueq5hQZ3hM9kG2JHC8M+dH nm+AMBgz9Af5Qh4yNRBZ3QeeyRBRuUIZ3o0Vnc7xEqyxgAbIJ0ImG29KvTHpGlFb/krU UBD113yA6//pzGdZEaRxZjUprIlx2nEsm3R5iSgwr1SJRSNQq53WTSnjESlKdOuHrZBe yYusTmoe4rcf3HR+Oyu0ihF9hbVV1qH0OjbxuuJEg0WIwKfEhfvYNnU9uvnrE6Lex3TX Xscw== X-Forwarded-Encrypted: i=1; AFNElJ8OaTZcbMTts+JiB3/U8UQiZOaGl12b1qFW9Qh5coOw86k0klSkVUgeDKz3G8niApQ5krQzfHgLD1xAhE+7@postgresql.org X-Gm-Message-State: AOJu0YzDCeotB5alrVteOOdTTqy4S2ULUb+opG2fXIsD9c9gpoXkGlbx uDEYPa1QrEiyF1gCiibajzKKy9emy/oWy1PpmZp8B4WWjASDYBddf+4f X-Gm-Gg: AeBDiesZMvRm4sZ3eS6+Q1v4WDyr4YI4PF8FucrE8nQFt/NGUyqzzVrWy4NjZTD1Xpl wyP4q+nfaTwTMvVsIjaTw4Se2L8IAw+YFXcw2u995gI1NZX1lf5tqO3CzJsfetlF4PfWfRXA+aJ c5A5g76/umkE4hsblzri4Sfm4uXvS/nuz7GjaucHTrelfKv5gsUmkA0kBU6JI5b4krPq2Lsbj7R uK4f2EnFlyLKaOlFqRmIbgy2t0hjsZQD938HoLXWmWMVJAebjZII6v9wexnXfaKyUU27OrozkJo D2wQIPWaLZj3L0BFma6GSH5YWBlmgoSr1CXfW/7rOlpim8Jv0KFEt4NykHCa1EQ6Fo24MTIIvWw MEYwOMxQEIFPTGL1RRCDDqJ+o8M4as8hBQZeY4NwFyeb21R+3Qd53icJ5kMfDIiDpySHqneFk/o CFtjxv2y2jwovcLzH9fHBUYrLmuzwrSuM1W2x9 X-Received: by 2002:a05:600c:4f88:b0:48a:563c:c8d6 with SMTP id 5b1f17b1804b1-48a844eb8bcmr115273215e9.7.1777643794134; Fri, 01 May 2026 06:56:34 -0700 (PDT) Received: from [172.31.5.233] ([165.225.26.248]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-48a8fee4d60sm13497485e9.19.2026.05.01.06.56.33 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 01 May 2026 06:56:33 -0700 (PDT) Message-ID: Date: Fri, 1 May 2026 15:56:32 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: Add pg_stat_vfdcache view for VFD cache statistics To: KAZAR Ayoub Cc: Tomas Vondra , Jakub Wartak , Pg Hackers References: <42776281-3603-4161-b47d-d4ffd2029e8c@vondra.me> <02cfc5e7-e152-4d2d-8b4b-e899d9901ed5@gmail.com> Content-Language: en-US From: David Geier In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 29.04.2026 15:45, KAZAR Ayoub wrote: >>>> The global cache stats is going to be virtually free (at least the >>>> hits/misses, I'm not sure about the number of entries and bytes), and >>>> it's obviously useful for tuning the max_files_per_process GUC. I'd even >>>> contemplate getting this into PG19, maybe. >> >> The number of used entries already exists, see nfile in fd.c. >> > Would one want the number of all entries (i.e SizeVfdCache see fd.c) or the > number of used entries (i.e entries with fds in use, which is nfile) ? I > thought of the first, that's what 0002 patch contains for the moment. I thought we would expose both. That way we can assess in the field if being able to shrink the cache would be useful. >> Including the total cache size would also be virtually free if we don't >> iterate over all VFDs each time, but update the size as we go. That >> would have to happen when resizing the cache and when populating / >> freeing a cache entry because extra memory is allocated / freed for >> Vfd::fileName. >> > Is it a big deal if we miss some bytes of filename globally ? It's not just some bytes. sizeof(struct vfd) is 56 bytes and fileName looks typically something like: - base/5/1249 - pg_wal/000000010000000000000001 - pg_wal/archive_status/000000010000000000000001.ready - pg_xact/0000 - pg_multixact/offsets/0000 File names can vary in length between 10 - 55 bytes, give or take. Most files will be table and index segments and WAL files. We could maybe add a fixed constant as "assumed average file name length" but I'm worried that might end up being quite wrong. -- David Geier