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 1vv3G6-000zC3-2P for pgsql-hackers@arkaria.postgresql.org; Wed, 25 Feb 2026 01:00: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 1vv3G5-0046cf-0n for pgsql-hackers@arkaria.postgresql.org; Wed, 25 Feb 2026 01:00:09 +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 1vv3G4-0046cX-2P for pgsql-hackers@lists.postgresql.org; Wed, 25 Feb 2026 01:00:08 +0000 Received: from mail-wm1-x332.google.com ([2a00:1450:4864:20::332]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1vv3G1-000000012ae-1ilu for pgsql-hackers@lists.postgresql.org; Wed, 25 Feb 2026 01:00:07 +0000 Received: by mail-wm1-x332.google.com with SMTP id 5b1f17b1804b1-48379a42f76so46908985e9.0 for ; Tue, 24 Feb 2026 17:00:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1771981205; cv=none; d=google.com; s=arc-20240605; b=KlX/R4ebxLEot2a4rBeeK0WlpFysd/egn9719FA4tEjVxnl6HDdJFlOjbJLltfyMh9 UuKvQQh4fZMHZy+GCIJdpXHQKu8/5qwiFNrvdtG5ZyZ6ojrPJ4Be4dokTDrKgmKDWWlz ivI6w1aehsS+VFTkx3XyeoRdzjet9k05eXQByhG3CbqsWV54R/FIybigT9iYs/1ZJBdL Kz2PC58++9BjP+4eQJ1n5Da5HkVmuLFoNkClwwiTg4T2nxxsGg2nFrnkLICTHcAqJvou BnAhD1ZZCnpTg5uc4UTDUD0JLqNrgryCNM8tWgcxy848n0Upgk5QGVXIAdTPy7NVRXjl yYLw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:dkim-signature; bh=SCIyvmxfdVvt9lN6tAF3GXf+D5mqi+e2BbhEiwvQTOo=; fh=y06JK7M31aNWpkMofCGnr80pxmdQp9myj6lkR7fJ+2Y=; b=agClQ8qOTeexgaSFIRU7YFw1RllAfp3ULbVG5vWvdalQAZoVop3oZE+vm9mN+F1gtG sCc6eAFToSc7w24T2LdSBkRYHcmsOwOyOo6a2VIgIgKoIKh52bC0wZ2zc1MhIdMFrwLD ziKOSJIEfidwSaUXNIM6OczfNEuCCgT4AOhEAmJLJZAY/8WdVwH9XzhPskQIlKHCW5d8 cW35gxzSU/R4Yr5Lb2DZM8XPNtHXCFXOAlssF/W0cNZFENkIiAK+HyMFEXIVLMEGA2VJ y6LwSFZgvc4vJCtCljSrCgY/5g/8LV9UqRJ8JCBUP8jGi3/9jE3JYnn5MvIV/3lrZcJA ji9Q==; darn=lists.postgresql.org ARC-Authentication-Results: i=1; mx.google.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1771981205; x=1772586005; darn=lists.postgresql.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=SCIyvmxfdVvt9lN6tAF3GXf+D5mqi+e2BbhEiwvQTOo=; b=TSdpBQHtfpEILHVDv/v+GRhw9eedIrJMcLj/KmziesUBI4rLEWxCVB0u0w+RTXNkFo 2MYoOMUSH9bXYBQNzzYEqLh23rm+cPksZd33OHLXv63Cm9SDZx+YXN7OlUznoodHMIOS GQefGpSG+k5a8wWK/iZ3m4NyHwklzmnyY3P65xS6UzqgjNooNLwdllBEVX+Do9XjE62Y QjpLh98pTNdkQpZBrLXziOArIzzStHzg+1RpSInyWI2W5BafdjiKoyOj4ReJoKFcGg3A 06P6CstoGt2N9eXPGYXy+FmWpX7I8uTcfgsUI+wSiqyF94tJutCTlApkWdBwuhobHbFe Y0+g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1771981205; x=1772586005; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=SCIyvmxfdVvt9lN6tAF3GXf+D5mqi+e2BbhEiwvQTOo=; b=glRFBKPcLl9q4QK4oWC8+hQ5hzcpLfK58n70m2pdP5DYiteeQtZ0yLSpJZxM/6xD9i MgcsHUpVMv1EMd24cHCmFEjjYOo9eRIKyVarMRNbSIvMzqStwg07TjRuaOeSAFYqJRPH yIgNVZYrT0Sr3eQ6yixe9BCAbV6LglEOBr7aJCKZA/GUKrYOksEN2aVbf42ZgORGdbAO n8IvIWB3ctE4d+6MYADNolk6ek26sW9LputVm9CFN6OfPeD/Bav4zpSNsR6287bOjRo5 UrjtPumtu02JkiG4jlIoVtDoUMlbO7EAiU7rYRkjDE7bsgKSzFl0wCF3iuigiI9Zr7Rp /30A== X-Forwarded-Encrypted: i=1; AJvYcCUVixdMXqHKofksHA6VSrZDKBir596pigBdNQTWNbekLV4xQIx+VrP5LChWtwqM7mbYAs2nHIuQFxo4xzuS@lists.postgresql.org X-Gm-Message-State: AOJu0Yy4Atw081JbU4U/SWISmwa2bMljQPwN/AS7XKeSENfukAA2ft2R Hc8BMRMlDHoMlBIUCDZYwSliQmOeheTWv2Wru0wLeLSig1+UnwPEfiNcLPq86PGsidMRrAr7e/9 seIKaZoyGEGDbgep9NIG132Dj+qHDwhs= X-Gm-Gg: AZuq6aKVnNjddxwOEQqousAIlexPBLpvdtg0GfUm+t/b+fkqI6a6d/UXNVBVtajuZgi y99Pm3sPzXESBYyWFoRnRlLfDAWyHjQVI8YJ2+mJoQ7thTTApeEYs4o4EUUFInTtFF8J2SYyhQl zoUJjUIWp8O59sK3pL//XrG9dcd7LmP8LAYi+aVHfa6kuEdwNSmiw1OBdDWqA9p2tbgG+p5/hAF tIvjMyHkZ62z/JqpXGkyG1bkysGiAlX0mVNRoFDxgKNL/E4ovKNCx6jGkWeoxD+74SYZeUJ/WJ9 Jugkx5DO2twqmLXgvQn2S1E8bzcp1EpuufRa+/sO2OL06+RTtXlqjkb7CHtHUyGXCl7oBLTs/0M +KwVfri+S X-Received: by 2002:a05:600c:620f:b0:483:129e:b573 with SMTP id 5b1f17b1804b1-483bef49d6fmr10601965e9.18.1771981204977; Tue, 24 Feb 2026 17:00:04 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: David Rowley Date: Wed, 25 Feb 2026 13:59:53 +1300 X-Gm-Features: AaiRm53lXBqH45iwrjkkF1PIfVnz3EgJ4-RSzRp2hTU_wpDySwzNjdS9JVdSsJc Message-ID: Subject: Re: More speedups for tuple deformation To: Andres Freund Cc: John Naylor , Chao Li , PostgreSQL Developers Content-Type: text/plain; charset="UTF-8" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Thanks for looking. On Wed, 25 Feb 2026 at 03:39, Andres Freund wrote: > ISTM we should just merge 0004. In my testing it's a very clear win, without, > afaict, any downsides. I'd like to get them in in sequence as I believe 0004 buys back some extra overheads such as the Min()s in slot_deform_heap_tuple(). If I were to do 0004 first, then wait a while, it might look more like I'm introducing a small regression. > > I'm not getting great results from benchmarking the 0005 patch. I > > verified that gcc does access the array without calculating the > > element address from scratch each time and calculates it once, then > > increments the pointer by sizeof(CompactAttribute). See the attached > > .csv for the results on the 3 machines I tested on. > > FWIW, where I had seen that be rather beneficial is the TupleDescCompactAttr() > at the start of the various loops, where the compiler has little choice to > compute the address of the tupdesc->compact_attrs[firstNeededCol]. That > matters only when only deforming a small number of columns, of course. oh ok. I wasn't aware that LEA's scaling factor can only be 1,2 4 or 8. With the 8-byte struct, the compiler should be able to do the shift and add as one operation, whereas with the 16-byte struct would require a separate shift and add. Looking at the generated code, with 0004, I see: 1c79: 48 c1 e2 04 shl rdx,0x4 1c7d: 48 8d 4c 15 20 lea rcx,[rbp+rdx*1+0x20] whereas with 0005 I see: 1c6b: 4a 8d 1c dd 00 00 00 lea rbx,[r11*8+0x0] Is that what you meant? > > I've also resequenced the patches to make the deform_bench test module > > part of the 0001 patch. This makes it easier to test the performance > > of master. > > What are your thoughts about merging the deform_bench tooling? I wonder if we > should have src/test/modules/benchmark_tools or such, so we can add a few more > micro-benchmarky tools over time? I'd like to see us give these tools a proper home. It helps lower the bar for anyone else who'd like to experiment at some future date, and also allows people to more easily test for performance regressions if they're forced to change related code. I've also got a tool that benchmarks the MemoryContext code which I keep in some local repo that I dig out from time to time. Given that, it's probably unlikely deform_bench would be the only extension in there if we did make a directory for these. On the otherhand, it does add some maintenance overhead, but IMO, helping to ensure various key routines are optimal is a worthy enough cause to make the maintenance overhead worthwhile. David