Re: can shared cache be swapped to disk?

From: Martijn van Oosterhout <kleptog(at)svana(dot)org>
To: Jeff Janes <jeff(dot)janes(at)gmail(dot)com>
Cc: flyusa2010 fly <flyusa2010(at)gmail(dot)com>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: can shared cache be swapped to disk?
Date: 2011-01-04 22:52:54
Message-ID: 20110104225253.GB30935@svana.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Tue, Jan 04, 2011 at 09:51:05AM -0800, Jeff Janes wrote:
> > Correct. The kernel ignores locking requests because it's a great way
> > to DOS a machine. For example, mlock() of large blocks of memory is
> > also not permitted for similar reasons.
>
> Does it ignore such requests in general, or only under certain situations?
>
> If the latter, do you know what those situations are?

Well, not in general, but for shared memory it's ignored (not sure
about if you're root). It used to be that shared memory was always
locked, which sounds like a great idea, until people started abusing it.

So now shared memory is on ethe same footing as other memory. Not sure
where I read this, I know it came up several years ago. I think it
changed back in 2.0 times.

> RLIMIT_MEMLOCK exists, it has a small default hard limit, and only
> root can increase that. If root has gone out of its way to grant the
> postgres user a higher limit, the kernel should respect that, at least
> up until the situation become truly desperate.

Like I said, not sure about how it works for root.

> Unfortunately it is hard to know what the kernel considers to be
> significant memory pressure.
>
> My experience (from mostly non-pgsql work) is that kernel has what I
> would consider enough cache memory to throw away, but for some reason
> doesn't throw it away but does more counter productive things instead.

Possibly. Everyone always considers their memory to be more important
than all other memory on the system, but the kernel has a much better
idea of what's going on than the user. That doesn't mean it's without
fault or couldn't be improved.

But if there's a bunch of shared memory not being accessed very often
and the kernel thinks it's better used somewhere else, it may be right.
Repeatable test cases in this area are really hard.

Have a nice day,
--
Martijn van Oosterhout <kleptog(at)svana(dot)org> http://svana.org/kleptog/
> Patriotism is when love of your own people comes first; nationalism,
> when hate for people other than your own comes first.
> - Charles de Gaulle

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Josh Berkus 2011-01-04 23:18:46 Re: Fixing GIN for empty/null/full-scan cases
Previous Message Dimitri Fontaine 2011-01-04 22:24:43 Re: Sync Rep Design