Re: SHM_LOCK under Linux ... do we use this?

Lists: pgsql-hackers
From: "Marc G(dot) Fournier" <scrappy(at)postgresql(dot)org>
To: pgsql-hackers(at)postgresql(dot)org
Subject: SHM_LOCK under Linux ... do we use this?
Date: 2005-08-17 20:26:34
Message-ID: 20050817172052.U1002@ganymede.hub.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers


Under FreeBSD, we have an option (kern.ipc.shm_use_phys=1) that doesn't
allow shared memory to be swap'd ... under Linux, there is apparently an
application level option that can be used for this purpose:

A privileged user can prevent or allow swapping of a shared memory
segment with the following cmds:

SHM_LOCK prevents swapping of a shared memory segment. The user
must fault in any pages that are required to be present
after ...

I've done a grep through the code, to see if its something that we do use, and
it doesn't seem to come back with anything ... I believe its considered
common knowledge that 'swapping' for a database is evil, so am wondering
if there is some way that we can make use of this to help reduce/eliminate
that from happening?

The "A privileged user can..." part makes me think no, but figured I'd ask
...

----
Marc G. Fournier Hub.Org Networking Services (http://www.hub.org)
Email: scrappy(at)hub(dot)org Yahoo!: yscrappy ICQ: 7615664


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Marc G(dot) Fournier" <scrappy(at)postgresql(dot)org>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: SHM_LOCK under Linux ... do we use this?
Date: 2005-08-17 22:20:43
Message-ID: 20087.1124317243@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

"Marc G. Fournier" <scrappy(at)postgresql(dot)org> writes:
> A privileged user can prevent or allow swapping of a shared memory
> segment with the following cmds:
> SHM_LOCK prevents swapping of a shared memory segment. The user
> must fault in any pages that are required to be present
> after ...

> I've done a grep through the code, to see if its something that we do use, and
> it doesn't seem to come back with anything ...

No, we don't. "privileged user" means root, so it's not possible for us
to set that.

regards, tom lane


From: "Marc G(dot) Fournier" <scrappy(at)postgresql(dot)org>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: SHM_LOCK under Linux ... do we use this?
Date: 2005-08-18 01:43:52
Message-ID: 20050817224258.H1002@ganymede.hub.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Wed, 17 Aug 2005, Tom Lane wrote:

> "Marc G. Fournier" <scrappy(at)postgresql(dot)org> writes:
>> A privileged user can prevent or allow swapping of a shared memory
>> segment with the following cmds:
>> SHM_LOCK prevents swapping of a shared memory segment. The user
>> must fault in any pages that are required to be present
>> after ...
>
>> I've done a grep through the code, to see if its something that we do use, and
>> it doesn't seem to come back with anything ...
>
> No, we don't. "privileged user" means root, so it's not possible for us
> to set that.

Ya, that's what I was figuring, but figured someone with more Linux
knowledge might know a 'loophole' we could exploit :)

----
Marc G. Fournier Hub.Org Networking Services (http://www.hub.org)
Email: scrappy(at)hub(dot)org Yahoo!: yscrappy ICQ: 7615664


From: "Qingqing Zhou" <zhouqq(at)cs(dot)toronto(dot)edu>
To: pgsql-hackers(at)postgresql(dot)org
Subject: Re: SHM_LOCK under Linux ... do we use this?
Date: 2005-08-18 09:14:02
Message-ID: de1jlh$22k1$1@news.hub.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers


""Marc G. Fournier"" <scrappy(at)postgresql(dot)org> writes
>
> I've done a grep through the code, to see if its something that we do use,
and
> it doesn't seem to come back with anything ... I believe its considered
> common knowledge that 'swapping' for a database is evil, so am wondering
> if there is some way that we can make use of this to help reduce/eliminate
> that from happening?
>

There are some similar flags in other OS could help us to keep the memory
resident in. However, it is not always a net win if we force it. This is
because other parts of the system (like fork a process) may need memory, so
the OS will pick up the "coldest" memory to be swapped. If we have already
use our memory intensively, I don't think we will be swapped. On the
contrary, if we force OS not to swap some memory, we may get other penalties
like our processes have to be sarcrificed.

Regards,
Qingqing


From: Jan Wieck <JanWieck(at)Yahoo(dot)com>
To: Qingqing Zhou <zhouqq(at)cs(dot)toronto(dot)edu>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: SHM_LOCK under Linux ... do we use this?
Date: 2005-09-20 20:13:57
Message-ID: 43306D85.9080808@Yahoo.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On 8/18/2005 5:14 AM, Qingqing Zhou wrote:
> ""Marc G. Fournier"" <scrappy(at)postgresql(dot)org> writes
>>
>> I've done a grep through the code, to see if its something that we do use,
> and
>> it doesn't seem to come back with anything ... I believe its considered
>> common knowledge that 'swapping' for a database is evil, so am wondering
>> if there is some way that we can make use of this to help reduce/eliminate
>> that from happening?
>>
>
> There are some similar flags in other OS could help us to keep the memory
> resident in. However, it is not always a net win if we force it. This is
> because other parts of the system (like fork a process) may need memory, so
> the OS will pick up the "coldest" memory to be swapped. If we have already
> use our memory intensively, I don't think we will be swapped. On the
> contrary, if we force OS not to swap some memory, we may get other penalties
> like our processes have to be sarcrificed.

If this happens often to be PostgreSQL's shared buffers, then you have
configured too many of them.

Jan

--
#======================================================================#
# It's easier to get forgiveness for being wrong than for being right. #
# Let's break this rule - forgive me. #
#================================================== JanWieck(at)Yahoo(dot)com #