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 1vvLVO-00EqoN-0X for pgsql-hackers@arkaria.postgresql.org; Wed, 25 Feb 2026 20:29:10 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1vvLVM-008V5P-0B for pgsql-hackers@arkaria.postgresql.org; Wed, 25 Feb 2026 20:29:08 +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 1vvLVK-008V5H-30 for pgsql-hackers@lists.postgresql.org; Wed, 25 Feb 2026 20:29:07 +0000 Received: from fhigh-b8-smtp.messagingengine.com ([202.12.124.159]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1vvLVG-00000001AqA-3mOU for pgsql-hackers@lists.postgresql.org; Wed, 25 Feb 2026 20:29:05 +0000 Received: from phl-compute-04.internal (phl-compute-04.internal [10.202.2.44]) by mailfhigh.stl.internal (Postfix) with ESMTP id 914947A013E; Wed, 25 Feb 2026 15:29:02 -0500 (EST) Received: from phl-frontend-03 ([10.202.2.162]) by phl-compute-04.internal (MEProxy); Wed, 25 Feb 2026 15:29:02 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=anarazel.de; h= cc:cc:content-type:content-type:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:subject :subject:to:to; s=fm3; t=1772051342; x=1772137742; bh=LVWTb9frhw jARyX73Op36DpMFLQrDNqdXmtZo1J5pDQ=; b=UZHVbd3QzQx3qbA8BoevJCxIU6 5Q8T/G61gn8JbpqOdCztRbk8CE/NhNKooXHGMioa4W0AfkOU+bEsmG1uNumgPTAH 6vyqTLJmvbPq63D4evLpbUXGYDLvquqVfwK/cOSslpg5XOWmbEFZXKqSbrM3vLE4 qU36b9OkGaClgiY/9LPPsuYtkObzvQhxKRqHGisDThWCvDIt5dJxF4x/HO/C/Xfx 91uslLyie5A99I33/bp0DBW0IOMOvmhULcTGAtNW9w5YYsLJzqnMMfgVGq1bWpbL Lnn8QZIfUOyDq4i8SYOnbmy/H7A+55FgFMFTI6aptdm/NMXin7UeMSKYfB0g== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:content-type:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:subject:subject:to :to:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm3; t= 1772051342; x=1772137742; bh=LVWTb9frhwjARyX73Op36DpMFLQrDNqdXmt Zo1J5pDQ=; b=vphKWJuzqpmChaTHB45iX7TbnjWL/ptdVtedWZovLUxqqyYu6DQ 03NGLVElqHRWSxyKv9VrpwBUzeHuxxlmkLv7y6kWJUJzYxJpUAXE//5oRuVOcsNV 2BcuMX951dij99pT6a6R9Sohiuc+ATnuKBuMqMc7vtxdKKqm8deC2s43yzSp/bkc DQzCFovosSDL8nj3uoAjwgP990n0RoAU1+qoJj+5ZOZQtWoJLeD3tbp4QFK7j8Gj UK6e3b9Z4kUUoTSGVOiSQvb99mZOaqcSpqL12ARZYu+dXsI4o20lmglfrv+sMLdT wb0ufzHWcr2+znoXtUobjc0OX3P09oiLiLQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefgedrtddtgddvgeegtdejucetufdoteggodetrf dotffvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfurfetoffkrfgpnffqhgenuceu rghilhhouhhtmecufedttdenucenucfjughrpeffhffvvefukfhfgggtuggjsehttdfstd dttddvnecuhfhrohhmpeetnhgurhgvshcuhfhrvghunhguuceorghnughrvghssegrnhgr rhgriigvlhdruggvqeenucggtffrrghtthgvrhhnpeeffffgledvffegtdevlefgtdeggf fhvdekgfegteeiveejkeetudelveejhfeugeenucevlhhushhtvghrufhiiigvpedtnecu rfgrrhgrmhepmhgrihhlfhhrohhmpegrnhgurhgvshesrghnrghrrgiivghlrdguvgdpnh gspghrtghpthhtohepgedpmhhouggvpehsmhhtphhouhhtpdhrtghpthhtohepughgrhho fihlvgihmhhlsehgmhgrihhlrdgtohhmpdhrtghpthhtohepjhhohhhntghnrgihlhhorh hlshesghhmrghilhdrtghomhdprhgtphhtthhopehlihdrvghvrghnrdgthhgrohesghhm rghilhdrtghomhdprhgtphhtthhopehpghhsqhhlqdhhrggtkhgvrhhssehlihhsthhsrd hpohhsthhgrhgvshhqlhdrohhrgh X-ME-Proxy: Feedback-ID: id4a34324:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 25 Feb 2026 15:29:01 -0500 (EST) Date: Wed, 25 Feb 2026 15:29:01 -0500 From: Andres Freund To: David Rowley Cc: John Naylor , Chao Li , PostgreSQL Developers Subject: Re: More speedups for tuple deformation Message-ID: References: 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: Archived-At: Precedence: bulk Hi, On 2026-02-25 13:05:14 -0500, Andres Freund wrote: > At least gcc is doing some truly weird shit in the > firstNonGuaranteed/firstNonCachedOffsetAttr loop "header" (i.e. just before > the first entrance to the loop) , which leads to the register pressure being > high, which leads to spilling on the stack, making the few-tuples case slower: > > [ lots of stuff trimmed ] > > I.e. the compiler creates an offset version of tts_values[tts_nvalid], > tts_isnull[tts_nvalid], which then creates register allocation pressure, > because later the original tts_values/tts_isnulll etc are accessed again and > thus the underlying registers are preserved. And this is all for zero gain, > from what I can tell, because the acceses are still done with indexed > addressing (like mov %rdi,(%r12,%rcx,8)), which would work just as > well if rcx were indexed based on attnum, not zero indexed within the loop. > > I see about a 10% improvement if I dissuade the compiler from doing that by > adding > __asm__ volatile ("" : "+r"(attnum) : :); > > In the loop body. > > > I'm getting to the point where I'd like to just hand write the assembler for > this stupid function. Gah. Huh. It, at least partially, seems to be related to using an integer for attnum et al. Due to us using -fwrapv, the compiler can't actually assume that an attnum++ won't overflow. An overflow would make the loop trip counts a lot more complicated. Even with that I don't understand how it ends up generating such crappy code, but since using size_t fixes it... Greetings, Andres Freund