Re: [COMMITTERS] pgsql: Move each SLRU's lwlocks to a separate tranche. - Mailing list pgsql-hackers

From Andres Freund
Subject Re: [COMMITTERS] pgsql: Move each SLRU's lwlocks to a separate tranche.
Date
Msg-id 20160411113138.amwskmlzi4wwhy2f@alap3.anarazel.de
Whole thread Raw
In response to Re: [COMMITTERS] pgsql: Move each SLRU's lwlocks to a separate tranche.  (Robert Haas <robertmhaas@gmail.com>)
Responses Re: [COMMITTERS] pgsql: Move each SLRU's lwlocks to a separate tranche.  (Robert Haas <robertmhaas@gmail.com>)
List pgsql-hackers
Hi,

On 2016-04-11 07:09:18 -0400, Robert Haas wrote:
> Attached patch does that.

Thanks.


> > Additionally, doesn't this obsolete
> >
> > /*
> >  * Preferred alignment for disk I/O buffers.  On some CPUs, copies between
> >  * user space and kernel space are significantly faster if the user buffer
> >  * is aligned on a larger-than-MAXALIGN boundary.  Ideally this should be
> >  * a platform-dependent value, but for now we just hard-wire it.
> >  */
> > #define ALIGNOF_BUFFER  32
> 
> I didn't go as far as trying to remove this; a few other random things
> are using it.

All of the places using it look like they actually rather should use
CACHELINEALIGN...


> diff --git a/src/backend/storage/ipc/shmem.c b/src/backend/storage/ipc/shmem.c
> index 1ad68cd..8e6cbdb 100644
> --- a/src/backend/storage/ipc/shmem.c
> +++ b/src/backend/storage/ipc/shmem.c
> @@ -112,6 +112,7 @@ void
>  InitShmemAllocation(void)
>  {
>      PGShmemHeader *shmhdr = ShmemSegHdr;
> +    char       *aligned;
>  
>      Assert(shmhdr != NULL);
>  
> @@ -139,6 +140,11 @@ InitShmemAllocation(void)
>      shmhdr->freeoffset += MAXALIGN(sizeof(slock_t));
>      Assert(shmhdr->freeoffset <= shmhdr->totalsize);
>  
> +    /* Make sure the first allocation begins on a cache line boundary. */
> +    aligned = (char *)
> +        (CACHELINEALIGN((((char *) shmhdr) + shmhdr->freeoffset)));
> +    shmhdr->freeoffset = aligned - (char *) shmhdr;
> +
>      SpinLockInit(ShmemLock);

In the patch attached to http://www.postgresql.org/message-id/20160411051004.yvniqb2pkc7re5k7@alap3.anarazel.de
I did this instead by fixing up the actual shared memory allocation,
which seems a tiny bit cleaner.  But the asserts added there seem like a
worthwhile addition to me.

Greetings,

Andres Freund



pgsql-hackers by date:

Previous
From: nummervet nummervet
Date:
Subject: Re[4]: [HACKERS] Execute ignoring cursor?
Next
From: David Steele
Date:
Subject: Re: 2016-03 Commitfest