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 1x1hGC-005MlO-0x for pgsql-hackers@arkaria.postgresql.org; Wed, 02 Sep 2026 09:28:00 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1x1hGB-00BmSa-0b for pgsql-hackers@arkaria.postgresql.org; Wed, 02 Sep 2026 09:27:59 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1x1hGA-00BmSS-2t for pgsql-hackers@lists.postgresql.org; Wed, 02 Sep 2026 09:27:58 +0000 Received: from mail-wm1-x336.google.com ([2a00:1450:4864:20::336]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1x1hG9-00000003c9S-1KoT for pgsql-hackers@postgresql.org; Wed, 02 Sep 2026 09:27:58 +0000 Received: by mail-wm1-x336.google.com with SMTP id 5b1f17b1804b1-499ae1c6471so4543795e9.3 for ; Wed, 02 Sep 2026 02:27:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1788341274; x=1788946074; darn=postgresql.org; h=content-transfer-encoding:content-type: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 :content-type; bh=XeA0TUAjYl5ViSIKXpQiaEg8WuR1kKSd0xNciR9/fwE=; b=dxPyoaw0dTRQQIeSsvSl3jLAqhuqD7WssfYjgSZ/vqTvMUYDBmnNch2c1XUQa9Z5nf KgnSP07FlSfjHqcCItX3PHhrA8VfGWwH6IVwxmox0fY/2wOJm4qIBwZ1g4SaAymPsQKf cuqjYRz7CImqlBduEVa5vw74Y/XdtjhkYjYpgfpG/VavKGrs0O8yNgSMTSyaM6ngP+3v hoR1W7pBfqbua+CvD2HbmAjYXlQBaaUy/BwjeJyBkQyJrbPEjfBAYrK/o3735BTLlGf7 IWzrUZsza25d0uHsYUmIMw8lcD94Wq+Y65o40lTq/LMBWkwwtPudQed4iuN9nzezgrNF RXXA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1788341274; x=1788946074; h=content-transfer-encoding:content-type: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:content-type; bh=XeA0TUAjYl5ViSIKXpQiaEg8WuR1kKSd0xNciR9/fwE=; b=O9DxcX/AvX1dzkRC5/4NLHzBT4Tb71VPoc2NEv4c6PpKdJeMGDEtC3vTi6u6EimAcT pKhXHJhWmEGNi0si07Q8lY+DgP5OmtHg1/+nTnrKDwzZEFppGK//y6T/dMxaPK+k9PCK 9uwFUnEKFEH+6Ie2jXxJL0FBu5YeuG+LGbdiWjXU7xrKx8loOtwbUWCz/++74Vuxelak zHlSC7Rp47dhUF3pUEIAORDTQkI3Tt9CwwK62++gnoQx9mBvvD3SSCJYZikC9bOr+DPM gRd9QZ6bV0jUl0r40iWK8UorY+i49T3LBV8pn3R/fQ82K42mN5Kiqdxh6a+7hE/4FOEg DaPw== X-Forwarded-Encrypted: i=1; AHgh+RpuTD2r56pwKqeevniw5VQLSswP+2ulPRQAgoC3wxFnLrELVx3e/j0bCT0IojyrGMENcP4OJ2501bc7Y3G0@postgresql.org X-Gm-Message-State: AFuF++nATgc7W6ov6XLNy3I32u5ktAz+AIkVoWKZSaJXCXnNHLfJmjv3 gQGhFCx+nxZOxo82qB0+qKnNG5azIdCuVpC4R6QR6CbVo/AX+zeNZ0SpnAcx6A== X-Gm-Gg: AR+sD11NukWBVyzPF2WMhqAiJN5z2BDc7fuTt4qZ8G036PLgcEtgSdGUl+AmyMsasOH M0Fpn1S/x60yNBLmnQyJNtAFBh0SscZfBHxh08VWGVWFxoUFTdKFzLKCnNaGjj9uKrWhGonc3FA fenb6wSALuK5iW6859L2VyywqvoEuK+q8JV7ocjofalZ7Qik2prmxGdklPTerTMN1qmD6NoB7nE nXTHIK4K+1ELsOfCc46lQMBb6WdCMmp/kNv8jpVpbMDRwk4Lz50TRLZRK5T7GBpICcyDD2vsj3g 9hD1k5/99EY93MGU8IBoJXcM3lbFZ/YvrxQEClP0AN+1rpD5ejmGUQdpps9NgTtGW0Uf3xRsPJy gsWWk+XiApaLDgXm+AbI8CHcJDMMPkpb14RcCddEXTxoxVZeZPLyCKmcHfAUmO6I/LfhQ2C+fDx MsugbflCXCdrteytw1mOb8dtSB80QcJEx+qm4yUKTiqjoAkc1+wEwlj1lFRwlzFw== X-Received: by 2002:a05:600c:3b11:b0:49c:dca4:94c with SMTP id 5b1f17b1804b1-49ce5843baemr57015395e9.13.1788341274420; Wed, 02 Sep 2026 02:27:54 -0700 (PDT) Received: from [172.31.5.233] ([165.225.27.25]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-48448e7315bsm5277021f8f.7.2026.09.02.02.27.53 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 02 Sep 2026 02:27:53 -0700 (PDT) Message-ID: <11d0df16-94b8-4223-87f7-2e84084a28af@gmail.com> Date: Wed, 2 Sep 2026 11:27:52 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: Add pg_stat_vfdcache view for VFD cache statistics To: Ayoub Kazar Cc: KAZAR Ayoub , Tomas Vondra , Jakub Wartak , Pg Hackers References: <42776281-3603-4161-b47d-d4ffd2029e8c@vondra.me> <02cfc5e7-e152-4d2d-8b4b-e899d9901ed5@gmail.com> <52677fc8-f57d-48c2-9415-6beb3ea6fa01@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 >>> I chose to keep an accurate running count of the memory footprint per >>> backend by tracking both the sizeof(Vfd) and the exact filename string >>> lengths. >>> >>> We add the string length to the total footprint when a file is opened, >> and >>> subtract it when the VFD is freed (i suppose this is not "Too much" of a >>> work done, although it's done in a bit hot place); v5 of the patch is >>> attached. >> Better use GetMemoryChunkSpace() instead of using strlen() + 1, to get >> the true allocation size. >> > That wouldn't work because filename is malloc'd and not palloc'd, which is > what GetMemoryChunkSpace() works on IIUC. > Am i correct here? That's interesting an interesting realization. You're right that we cannot use GetMemoryChunkSpace() in that case. However, I'm wondering if the better approach wouldn't be to change fd.c to use a long-lived memory context. Then all bookkeeping would happen automatically and the memory size could simply be reported via existing memory context stats infrastructure. Not entirely sure though if there's some roadblock when switching to a memory context. -- David Geier