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 1wFoZu-005a9r-2M for pgsql-hackers@arkaria.postgresql.org; Thu, 23 Apr 2026 07:34:27 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1wFoZt-000QqP-2w for pgsql-hackers@arkaria.postgresql.org; Thu, 23 Apr 2026 07:34:25 +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 1wFoZt-000QqH-22 for pgsql-hackers@lists.postgresql.org; Thu, 23 Apr 2026 07:34:25 +0000 Received: from mail-wm1-x32f.google.com ([2a00:1450:4864:20::32f]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1wFoZr-00000002bvQ-35q5 for pgsql-hackers@postgresql.org; Thu, 23 Apr 2026 07:34:25 +0000 Received: by mail-wm1-x32f.google.com with SMTP id 5b1f17b1804b1-483487335c2so61800045e9.2 for ; Thu, 23 Apr 2026 00:34:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1776929663; x=1777534463; 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=d3cOkqM5JCMf0QlZ4vD+mPp2joYHiz1XMUx81Su7aP8=; b=OaMVv6LC+RbfCYTGiQ13TUKV452nigt8Qv5oXME/4aL67MoxROUs8Pozfcnz4ToWlI bNDC9c+rGJztqnX54jl+2eOQmvjNF87thFUwFcStrify0TY8UxB8XE0ijWqsph5NAAZP aQpPHfFsXfnpzW2NaVCXpqqz39I7LE3b54y+Y7DUSMUJQK+RjQn7JZOqzFKxx4FQOHnI CQSyS0XuB4FMPFbtHYvbkh5Gqn+QToW2j60QOdcGzTvI5n0mlIHQQRCamUF6e7/N6VHj bkWr6q0gjpWRrpgErLTpmarORB/anMEZXjbtyWY0UvaEpNjzLNrfdF9Tb7UCpjOl+HHa HKAA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1776929663; x=1777534463; 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=d3cOkqM5JCMf0QlZ4vD+mPp2joYHiz1XMUx81Su7aP8=; b=W7EaDKBBnXcVjaoXS+p4lFSlGviZtD/1oMW4kmfzqbSMdqYUKeBh6AF1tLxG5CGMpi wrlBkOuPxh9Kb6UHRUIcEVFULmacKaCysyBVg6wcwjUvEHwmDLEnSoHRpdMtl93NWL2D y5RPavJ1i+aOnFiyAxJpF1qYVGzcG8j+nVrPpQSG+aK1nOG17qICCHlGCiQDN0uhz6sE EuJw9wd5LYBKr9eNOny7gMYR9G3NII7QuADDRiB9y2wLrAEd373TWXgNyym4LgHi94sk lyniw4B3MOGKV1e/AXgTHV9GSFz2DAx/4Z9VfhKu2MA78lQ7lmWE4FgYgKFlDk3X4tkH dYeg== X-Forwarded-Encrypted: i=1; AFNElJ/JrWmXKz9ktWhLrOHPgWOTV1rBcASCtY38cikawKmwZpOIlfy+UPeUe7sd8rkPo4NgR/gLDAD+Yx0lchdN@postgresql.org X-Gm-Message-State: AOJu0YzOFmxvL91cjOEvaXpPW+s9vwaenZ+HIB/BprbimKZxB8+eE7AH zQd4wzaWP9EApcZE1+oqrWPPo14I8LA+mhDCu0D7lKFy/HQbCiilSkOZ X-Gm-Gg: AeBDievukDDXVVxzBBYhkpZesta4ag+pBObJ9al+/M6YEfJ053+LgCUxyxgM5qYaUvL y4AVVEX06l0xztR0co5pN1ef1nP/ukAU4GoUrZvyHIAAhf7mlBoTHanzdyw+6SJL9dIoOYOiHfk k6hMTk9bm3jTFAnb0PJTXFO+SYu/m2h7cEoAqPDohNMa0fmLuG3aEGlbjVS4NhiGHBiXA24xQb3 77yHElAUiwELGQXY7MlwCPdoURqUuvtaUzFONvJeJlMW3r/iBvfozrh7MSn3RtfVIVbgxJfiCzG WXf6uL0Xayqds8RZFaX/HJl3gpFEngvDG67bkvsKHN6skM88YZ010EiB8ojBDpfbn5mOxAlbmNw zTHeifM0EjGmMAsFvZ2yJFMJUGKujSOSa8gVvuJHwa75X4XyBC4hK/6Ie38n2tQd5Oq9T42aWUi lxx2wwaDsECIzxksWX/25b/ItvFe1I0Y8Nq8tD/p9f X-Received: by 2002:a05:600c:a303:b0:48a:5576:a28a with SMTP id 5b1f17b1804b1-48a5576a618mr120494665e9.0.1776929662437; Thu, 23 Apr 2026 00:34:22 -0700 (PDT) Received: from [172.31.5.233] ([165.225.27.16]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-488fc1cfbf2sm517876315e9.15.2026.04.23.00.34.21 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 23 Apr 2026 00:34:21 -0700 (PDT) Message-ID: <02cfc5e7-e152-4d2d-8b4b-e899d9901ed5@gmail.com> Date: Thu, 23 Apr 2026 09:34:20 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: Add pg_stat_vfdcache view for VFD cache statistics To: KAZAR Ayoub , Tomas Vondra Cc: Jakub Wartak , Pg Hackers References: <42776281-3603-4161-b47d-d4ffd2029e8c@vondra.me> 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 Hi! I finally got around taking a look at this patch. On 03.04.2026 15:53, KAZAR Ayoub wrote: >> - I think it would be useful to report how many file descriptors we >> are allowed to open (it's less than max_files_per_process, depending >> on the ulimits etc.) >> > Agree, This should be max_safe_fds calculated by postmaster, I added this > but let me know if its acceptable to export max_safe_fds in the way I did. An alternative to including it in the view would be using a GUC of type PGC_INTERNAL. That seems more inline with how we expose other PostgreSQL internal read-only variables that don't change. Or is there an advantage to including max_safe_fds in the view? >> 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. 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. I'm happy to code this up if there's agreement that it's sensible to include it, in the current version of the patch or a follow-up patch. Beyond that: While looking through the code I saw a mistake (repetition of "that") in a comment in existing code. Maybe you want to fix that as well right away? /* * For variable-numbered stats: flush pending stats. Required if pending * data is used. See flush_static_cb when dealing with stats data that * that cannot use PgStat_EntryRef->pending. */ bool (*flush_pending_cb) (PgStat_EntryRef *sr, bool nowait); The indentation of the type at the end of the following two structs is inconsistent with the rest of the files. typedef struct PgStatShared_VfdCache { /* lock protects ->stats */ LWLock lock; PgStat_VfdCacheStats stats; } PgStatShared_VfdCache; typedef struct PgStat_VfdCacheStats { PgStat_Counter vfd_hits; /* fd was open, no open() was needed */ PgStat_Counter vfd_misses; /* fd was VFD_CLOSED, open() was required */ TimestampTz stat_reset_timestamp; } PgStat_VfdCacheStats; Apart from these nit comments the patch looks good to me. -- David Geier