Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1h9u7c-0003w4-0Z for pgsql-committers@arkaria.postgresql.org; Fri, 29 Mar 2019 16:12:48 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1h9u7a-0002mb-Jr for pgsql-committers@arkaria.postgresql.org; Fri, 29 Mar 2019 16:12:46 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1h9u7a-0002k2-Bq; Fri, 29 Mar 2019 16:12:46 +0000 Received: from out1-smtp.messagingengine.com ([66.111.4.25]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1h9u7W-0003co-7d; Fri, 29 Mar 2019 16:12:45 +0000 Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailout.nyi.internal (Postfix) with ESMTP id 9D34821F93; Fri, 29 Mar 2019 12:12:40 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute5.internal (MEProxy); Fri, 29 Mar 2019 12:12:40 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=anarazel.de; h= date:from:to:cc:subject:message-id:references:mime-version :content-type:in-reply-to; s=fm1; bh=5chOgmjCG75r97Rd64rqg7NGx6Q LiFSowkOpQeuk+6U=; b=r5SW5JLS7HeR8YOVdN34QJDCvJ/MhKb0zaGU8X6sISb ZkuaJg9JGl86D2jAUfiKjLs/IoOu8jR1uwGBlJYyfEDM9FVJILCERWZKLau2INqW 8TgIxo5WDfSumCV9zBasZQz02VDHhK3nnedCxNaTHR8tS6cace6sW7kLC57JCkw1 JaTToHPVC2O/bMgmzzqg8+rGtyrtNbRIYHaR7c2Oq0gF+eosKeBcS8lFdNeupVxt 5no9uHk0eC3zgk3rQZjqa17uw7FWuXCu4Ap+0rDzH3H+UnYg86reJtL0PekTgZxS d5HgAFJV6QLkXH3k0wLPtQNd/vn2HoMBX7aHXzD71Gg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm2; bh=5chOgm jCG75r97Rd64rqg7NGx6QLiFSowkOpQeuk+6U=; b=2PQO8UsXepfHKRQCdVBX8X jJ4wGiJWfZ+Hy7N73+tMWWIK3s7bwxXXXyZhd14Smvg36LVKQW6NKiYNmuznPPLm MZm2wKD7GSa4FN8z7GXFpOyP1qCsHPTJqV9kzSatwJIrmunh4/GJW90PqUanqoCl J4uSrY35XXQrT86gfn+T9Vsyn1ikhuotVmqzRkHjNF4v+JB9bndtuv/0PfPRCIlC E3hyoMFLGxdlbRrdj1TVCNjjyyktTNNI+sY/kir6QsmXtTdnDsUBGq9Z6Yd0MuFO Rd4v7iMDfU6MjxjuRA7anaDCFW3MDvLyfkgM9xeq/g5v6cIpzHQYAgaxTmw/YiJQ == X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedutddrkeejgdehlecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpeffhffvuffkfhggtggujgesthdtredttddtvdenucfhrhhomheptehnughrvghs ucfhrhgvuhhnugcuoegrnhgurhgvshesrghnrghrrgiivghlrdguvgeqnecukfhppedvtd ekrdehgedrgeegrddvtddvnecurfgrrhgrmhepmhgrihhlfhhrohhmpegrnhgurhgvshes rghnrghrrgiivghlrdguvgenucevlhhushhtvghrufhiiigvpedt X-ME-Proxy: Received: from intern.anarazel.de (unknown [208.54.44.202]) by mail.messagingengine.com (Postfix) with ESMTPA id 8FB5310395; Fri, 29 Mar 2019 12:12:39 -0400 (EDT) Date: Fri, 29 Mar 2019 09:12:38 -0700 From: Andres Freund To: Simon Riggs Cc: pgsql-committers , PostgreSQL Hackers Subject: Re: pgsql: Compute XID horizon for page level index vacuum on primary. Message-ID: <20190329161238.eyrmdtofbzmapvyv@alap3.anarazel.de> References: <20190329152906.356icmttz7yjgsyh@alap3.anarazel.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Hi, On 2019-03-29 15:58:14 +0000, Simon Riggs wrote: > On Fri, 29 Mar 2019 at 15:29, Andres Freund wrote: > > That's far from a trivial feature imo. It seems quite possible that we'd > > end up with increased overhead, because the current logic can get away > > with only doing hint bit style writes - but would that be true if we > > started actually replacing the item pointers? Because I don't see any > > guarantee they couldn't cross a page boundary etc? So I think we'd need > > to do WAL logging during index searches, which seems prohibitively > > expensive. > > > > Don't see that. > > I was talking about reusing the first 4 bytes of an index tuple's > ItemPointerData, > which is the first field of an index tuple. Index tuples are MAXALIGNed, so > I can't see how that would ever cross a page boundary. They're 8 bytes, and MAXALIGN often is 4 bytes: struct ItemPointerData { BlockIdData ip_blkid; /* 0 4 */ OffsetNumber ip_posid; /* 4 2 */ /* size: 6, cachelines: 1, members: 2 */ /* last cacheline: 6 bytes */ }; struct IndexTupleData { ItemPointerData t_tid; /* 0 6 */ short unsigned int t_info; /* 6 2 */ /* size: 8, cachelines: 1, members: 2 */ /* last cacheline: 8 bytes */ }; So as a whole they definitely can cross sector boundaries. You might be able to argue your way out of that by saying that the blkid is going to be aligned, but that's not that trivial, as t_info isn't guaranteed that. But even so, you can't have unlogged changes that you then rely on. Even if there's no torn page issue. Currently BTP_HAS_GARBAGE and ItemIdMarkDead() are treated as hints - if we want to guarantee all these are accurate, I don't quite see how we'd get around WAL logging those. > > And I'm also doubtful it's worth it because: > > > > > Since this point of the code is clearly going to be a performance issue > > it > > > seems like something we should do now. > > > > I've tried quite a bit to find a workload where this matters, but after > > avoiding redundant buffer accesses by sorting, and prefetching I was > > unable to do so. What workload do you see where this would be really be > > bad? Without the performance optimization I'd found a very minor > > regression by trying to force the heap visits to happen in a pretty > > random order, but after sorting that went away. I'm sure it's possible > > to find a case on overloaded rotational disks where you'd find a small > > regression, but I don't think it'd be particularly bad. > The code can do literally hundreds of random I/Os in an 8192 blocksize. > What happens with 16 or 32kB? It's really hard to construct such cases after the sorting changes, but obviously not impossible. But to make it actually painful you need a workload where the implied randomness of accesses isn't already a major bottleneck - and that's hard. This has been discussed publically for a few months... Greetings, Andres Freund