Re: Double shared memory allocation for SLRU LWLocks

From: Teodor Sigaev <teodor(at)sigaev(dot)ru>
To: Alexander Korotkov <a(dot)korotkov(at)postgrespro(dot)ru>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Double shared memory allocation for SLRU LWLocks
Date: 2017-07-12 11:03:23
Message-ID: 5bf227e7-b9a8-99f9-c79c-0f01fb2a11a8@sigaev.ru
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

> It seems to me that we're allocating shared memory for SLRU lwlocks twice,
> unless I'm missing something.
I think you are right.

Did you check previous versions? i.e. should it be applyed to previous
branches?? I suppose yes, to minimize code difference.

Also I'd like an idea to add Assert(offset <= SimpleLruShmemSize(nslots, nlsns))
at the end of SimpleLruInit()

>
> SimpleLruShmemSize() calculates total SLRU shared memory size including lwlocks
> size.
>
> SimpleLruInit() starts with line
>
> shared = (SlruShared) ShmemInitStruct(name,
> SimpleLruShmemSize(nslots, nlsns),
> &found);
>
> which allocates SLRU shared memory (LWLocks size is included because
> SimpleLruShmemSize() is used for size computation).
>
> Following line allocates shared memory for LWLocks again:
> shared->buffer_locks = (LWLockPadded *) ShmemAlloc(sizeof(LWLockPadded) * nslots);
>
> Attached patch fixes that by removing extra ShmemAlloc for SLRU.
>
> ------
> Alexander Korotkov
> Postgres Professional: http://www.postgrespro.com
> The Russian Postgres Company
>
>
>

--
Teodor Sigaev E-mail: teodor(at)sigaev(dot)ru
WWW: http://www.sigaev.ru/

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message K S, Sandhya (Nokia - IN/Bangalore) 2017-07-12 11:20:58 Re: [HACKERS] Postgres process invoking exit resulting in sh-QUIT core
Previous Message Sandeep Thakkar 2017-07-12 11:02:45 PostgreSQL10 beta2 with ICU - initdb fails on MacOS