On Thu, Oct 12, 2023 at 9:27 AM Thomas Munro <thomas.mu...@gmail.com> wrote: > On Thu, Oct 12, 2023 at 9:05 AM Robert Haas <robertmh...@gmail.com> wrote: > > But if we do want to keep those cross-checks, why not take what Thomas > > proposed a little further and move all of xlp_sysid, xlp_seg_size, and > > xlp_xlog_blcksz into XLOG_CHECKPOINT_REDO? Then long and short page > > headers would become identical. > > FTR that's exactly what I was trying to say.
And to be extra double explicit, the point of that is to kill the 'div' instruction that Andres was complaining about, because now the division depends only on compile time constants so it can be done with multiplication and bitswizzling tricks. For example, when X is a variable I get: *a = n / X; 0x0000000000000003 <+3>: mov %rdi,%rax 0x0000000000000006 <+6>: xor %edx,%edx 0x0000000000000008 <+8>: divq 0x0(%rip) # 0xf <f+15> 0x0000000000000011 <+17>: mov %rax,(%rsi) *b = n % X; 0x000000000000000f <+15>: xor %edx,%edx 0x0000000000000014 <+20>: mov %rdi,%rax 0x0000000000000017 <+23>: divq 0x0(%rip) # 0x1e <f+30> 0x000000000000001e <+30>: mov %rdx,(%rcx) ... but when it's the constant 8192 - 24 I get: *a = n / X; 0x0000000000000000 <+0>: movabs $0x2018120d8a279db7,%rax 0x000000000000000d <+13>: mov %rdi,%rdx 0x0000000000000010 <+16>: shr $0x3,%rdx 0x0000000000000014 <+20>: mul %rdx 0x0000000000000017 <+23>: shr $0x7,%rdx 0x000000000000001b <+27>: mov %rdx,(%rsi) *b = n % X; 0x000000000000001e <+30>: imul $0x1fe8,%rdx,%rdx 0x0000000000000025 <+37>: sub %rdx,%rdi 0x0000000000000028 <+40>: mov %rdi,(%rcx)