Re: More speedups for tuple deformation

From: Zsolt Parragi <zsolt(dot)parragi(at)percona(dot)com>
To: David Rowley <dgrowleyml(at)gmail(dot)com>
Cc: Andres Freund <andres(at)anarazel(dot)de>, John Naylor <johncnaylorls(at)gmail(dot)com>, Chao Li <li(dot)evan(dot)chao(at)gmail(dot)com>, PostgreSQL Developers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: More speedups for tuple deformation
Date: 2026-02-24 18:33:19
Message-ID: CAN4CZFOqX_Mdjvw66tKrKAuv5zpwiz_EiGjH=JvBBDq-a+G+YQ@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hello

+ * We expect that 'bits' contains at least one 0 bit somewhere in the mask,
+ * not necessarily < natts.
+ */

Is this precondition really enough?

Let's say we have 20 attributes, only attribute 20 is NULL
Caller requests natts=8

That sets lastByte = 1, loop only checks bits[0], which is 0xFF, exits
with bytenum=1, bits[1] is also 0xFF

Then we execute

+ res += pg_rightmost_one_pos32(~bits[bytenum]);

where ~0xFF = 0

+ /* convert the lower 4 bits of null bitmap word into 32 bit int */
+ isnull_8 = (nullbyte & 0xf) * SPREAD_BITS_MULTIPLIER_32;
+
+ /*
+ * convert the upper 4 bits of null bitmap word into 32 bit int, shift
+ * into the upper 32 bit
+ */
+ isnull_8 |= ((uint64) ((nullbyte >> 4) * SPREAD_BITS_MULTIPLIER_32)) << 32;
+
+ /* mask out all other bits apart from the lowest bit of each byte */
+ isnull_8 &= UINT64CONST(0x0101010101010101);
+ memcpy(isnull, &isnull_8, sizeof(uint64));

Won't this mix up column numbers on big-endian systems?

Subject: [PATCH v9 1/5] Introduce deform_bench test module

For benchmaring tuple deformation.
---

Typo: should be benchmarking

+ * firstNonGuaranteedAttr stores the index to info the compact_attrs array for

to info should be "into"?

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2026-02-24 18:50:33 Re: pgsql: libpq: Grease the protocol by default
Previous Message Alvaro Herrera 2026-02-24 18:29:17 Re: Adding REPACK [concurrently]