Re: Lowering the default wal_blocksize to 4K - Mailing list pgsql-hackers

From Thomas Munro
Subject Re: Lowering the default wal_blocksize to 4K
Date
Msg-id CA+hUKG+HHAG6dYkjjJNaRk38K5e9ucaoPoyBeOHDUcMS+48s7g@mail.gmail.com
Whole thread Raw
In response to Re: Lowering the default wal_blocksize to 4K  (Thomas Munro <thomas.munro@gmail.com>)
List pgsql-hackers
On Thu, Oct 12, 2023 at 9:27 AM Thomas Munro <thomas.munro@gmail.com> wrote:
> On Thu, Oct 12, 2023 at 9:05 AM Robert Haas <robertmhaas@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)



pgsql-hackers by date:

Previous
From: Thomas Munro
Date:
Subject: Re: Lowering the default wal_blocksize to 4K
Next
From: Alena Rybakina
Date:
Subject: Re: A new strategy for pull-up correlated ANY_SUBLINK