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 1rOMnj-003aiU-Ed for pgsql-hackers@arkaria.postgresql.org; Fri, 12 Jan 2024 19:02:43 +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 1rOMni-004dm2-2Y for pgsql-hackers@arkaria.postgresql.org; Fri, 12 Jan 2024 19:02:42 +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 1rOMnh-004dlt-Pe for pgsql-hackers@lists.postgresql.org; Fri, 12 Jan 2024 19:02:41 +0000 Received: from mail-ot1-x32f.google.com ([2607:f8b0:4864:20::32f]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1rOMnf-001EuM-5o for pgsql-hackers@postgresql.org; Fri, 12 Jan 2024 19:02:40 +0000 Received: by mail-ot1-x32f.google.com with SMTP id 46e09a7af769-6dc36e501e1so4651954a34.1 for ; Fri, 12 Jan 2024 11:02:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1705086157; x=1705690957; darn=postgresql.org; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=o1mcQveW8yssJAh+mb3n8QhmNO7rnj22cFZpnNy5TgQ=; b=WhycSzVuZAosGqi3tNBLe5RMizOwV70vRagC5jVfiFwQs56rKSTG9fTcVElT3c/Evk ey73ui00xSyrOIy5lOdoSRcZxr6qwcfkqrItO/iZHYf8luGhS1qfkaJJFubdov4yHqoo qX8pidFCFGbDNUXuwHQzQUp8EV+TJ0HLj1gkz+9D8pR0TZDgMTpvAIbDeYNud1P9mhlK 8wFN7MgSywpcUQjbh8KZLhPwz9TAmGeTTCKIxo4/cfeGyR8qjDitgUTNc5XJYiEfUe6Z A0iiImYqiluRBCT4KvMqkfh0IIotN1lJd3pL49GdM4l6pksDlJJYgeSI0p3A6ZK7JdpW 8XCA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1705086157; x=1705690957; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=o1mcQveW8yssJAh+mb3n8QhmNO7rnj22cFZpnNy5TgQ=; b=Xo15+QPBy3TimKL2/mqL5r4a/aQ3/ZFbOFdUnJ8Jf0BMxWA5FU5ameCbF2wHWew6Yg fqVnLqGllUryL0MDh+Rdmwv5Ign+XEZoLj8Bvdr8GuRGYFLQ0Zu1khIHDcbpFPYEh4vN pSQj8/soMzTWKDBp4yqCPuuY8Can6uYqvW+PCcIE7NpFqZIqRUGjtU3O0ifTHUPDhxnB 5DCCzC1Iact8i3LGjBWWB3Wc0O0TDkiJu5TUadLkJjh+OXue3Dk08ox3mq3SxOGrCpXK gPPFOJ2yuYFDhQBpC3dS1ETN2WkvyMuGCP2GMDDO4FyDiXX8VynYCXtt4uHeVNPmFCxy IPIg== X-Gm-Message-State: AOJu0YxSFnD3AMSW4HaMZTVVKb3EavGVRiy+Je6j/1hfSgMvZjcRPTxS pzdgFxumTcceoW3MJu/Ei3uzZ40cH/wA X-Google-Smtp-Source: AGHT+IF1r4aIVsNhsP+S592evILtK12A4QDpKdNWUdEg9k9uwo7jEO8KhMm4buonRhJ2xIPqHbmWVQ== X-Received: by 2002:a05:6870:659f:b0:203:b530:2a6a with SMTP id fp31-20020a056870659f00b00203b5302a6amr2092961oab.76.1705086157494; Fri, 12 Jan 2024 11:02:37 -0800 (PST) Received: from [192.168.2.15] (070-113-014-216.res.spectrum.com. [70.113.14.216]) by smtp.gmail.com with ESMTPSA id r15-20020a9d750f000000b006dde30f0c9csm688966otk.81.2024.01.12.11.02.36 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 12 Jan 2024 11:02:37 -0800 (PST) Message-ID: <23a0cec3-6880-4608-b066-c1ebd8dff902@gmail.com> Date: Fri, 12 Jan 2024 13:02:33 -0600 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: Confine vacuum skip logic to lazy_scan_skip Content-Language: en-US To: Melanie Plageman , Nazir Bilal Yavuz Cc: Andres Freund , Pg Hackers , Heikki Linnakangas , Thomas Munro References: <20240104202309.77h5llrambkl5a3m@awork3.anarazel.de> From: Jim Nasby In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 1/11/24 5:50 PM, Melanie Plageman wrote: > On Fri, Jan 5, 2024 at 5:51 AM Nazir Bilal Yavuz wrote: >> >> On Fri, 5 Jan 2024 at 02:25, Jim Nasby wrote: >>> >>> On 1/4/24 2:23 PM, Andres Freund wrote: >>> >>> On 2024-01-02 12:36:18 -0500, Melanie Plageman wrote: >>> >>> Subject: [PATCH v2 1/6] lazy_scan_skip remove unnecessary local var rel_pages >>> Subject: [PATCH v2 2/6] lazy_scan_skip remove unneeded local var >>> nskippable_blocks >>> >>> I think these may lead to worse code - the compiler has to reload >>> vacrel->rel_pages/next_unskippable_block for every loop iteration, because it >>> can't guarantee that they're not changed within one of the external functions >>> called in the loop body. >>> >>> Admittedly I'm not up to speed on recent vacuum changes, but I have to wonder if the concept of skipping should go away in the context of vector IO? Instead of thinking about "we can skip this range of blocks", why not maintain a list of "here's the next X number of blocks that we need to vacuum"? >> >> Sorry if I misunderstood. AFAIU, with the help of the vectored IO; >> "the next X number of blocks that need to be vacuumed" will be >> prefetched by calculating the unskippable blocks ( using the >> lazy_scan_skip() function ) and the X will be determined by Postgres >> itself. Do you have something different in your mind? > > I think you are both right. As we gain more control of readahead from > within Postgres, we will likely want to revisit this heuristic as it > may not serve us anymore. But the streaming read interface/vectored > I/O is also not a drop-in replacement for it. To change anything and > ensure there is no regression, we will probably have to do > cross-platform benchmarking, though. > > That being said, I would absolutely love to get rid of the skippable > ranges because I find them very error-prone and confusing. Hopefully > now that the skipping logic is isolated to a single function, it will > be easier not to trip over it when working on lazy_scan_heap(). Yeah, arguably it's just a matter of semantics, but IMO it's a lot clearer to simply think in terms of "here's the next blocks we know we want to vacuum" instead of "we vacuum everything, but sometimes we skip some blocks". -- Jim Nasby, Data Architect, Austin TX