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

From: Andres Freund <andres(at)anarazel(dot)de>
To: Robert Haas <robertmhaas(at)gmail(dot)com>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: [COMMITTERS] pgsql: Move each SLRU's lwlocks to a separate tranche.
Date: 2016-04-11 11:31:38
Message-ID: 20160411113138.amwskmlzi4wwhy2f@alap3.anarazel.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers 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

In response to

Responses

Browse pgsql-committers by date

  From Date Subject
Next Message Fujii Masao 2016-04-11 12:29:17 pgsql: Fix documented return type of pg_logical_emit_message() in func.
Previous Message Robert Haas 2016-04-11 11:09:18 Re: [COMMITTERS] pgsql: Move each SLRU's lwlocks to a separate tranche.

Browse pgsql-hackers by date

  From Date Subject
Next Message David Steele 2016-04-11 11:35:27 Re: 2016-03 Commitfest
Previous Message nummervet nummervet 2016-04-11 11:11:56 Re[4]: [HACKERS] Execute ignoring cursor?