Обсуждение: Swapping on Solaris

Поиск
Список
Период
Сортировка

Swapping on Solaris

От
"Kevin Schroeder"
Дата:
Hello,
    I'm running PostgreSQL on a Solaris 8 system with 2GB of RAM and I'm
having some difficulty getting PostgreSQL to use the available RAM.  My RAM
settings in postgresql.conf are

shared_buffers = 8192   # min 16, at least max_connections*2, 8KB each
sort_mem = 131072               # min 64, size in KB
vacuum_mem = 131072             # min 1024, size in KB

Ignoring the fact that the sort and vacuum numbers are really high, this is
what Solaris shows me when running top:

Memory: 2048M real, 1376M free, 491M swap in use, 2955M swap free

For some reason I have 1.25GB of free RAM but PostgreSQL seems compelled to
swap to the hard drive rather than use that RAM.  I have the shared buffers
set as high as the Solaris kernel will let me.  I also know that Solaris
will cache frequently used files in RAM, thereby lowering the amount of RAM
available to an application, but my understanding is that Solaris will dump
that cache if an application or the kernel itself requires it.

    The system has about 1,000 active email users using unix mailboxes which
could what is keeping the database from exploiting as much RAM as available
but my primary concern is to allow PostgreSQL to use as much RAM as it
requires without swapping.

    What can I do to force the system to allow PostgreSQL to do this?

Regards,
Kevin Schroeder


Re: Swapping on Solaris

От
Mark Kirkwood
Дата:
Kevin Schroeder wrote:
>
>
> Ignoring the fact that the sort and vacuum numbers are really high, this
> is what Solaris shows me when running top:
>
> Memory: 2048M real, 1376M free, 491M swap in use, 2955M swap free
>
Maybe check the swap usage with 'swap -l' which reports reliably if any
(device or file) swap is actually used.

I think Solaris 'top' does some strange accounting to calculate the
'swap in use' value (like including used memory).

It looks to me like you are using no (device or file) swap at all, and
have 1.3G of real memory free, so could in fact give Postgres more of it :-)

regards

Mark


Re: Swapping on Solaris

От
"Matt Casters"
Дата:
> Kevin Schroeder wrote:
> It looks to me like you are using no (device or file) swap at all, and
> have 1.3G of real memory free, so could in fact give Postgres more of it :-)
>

Indeed.
If you DO run into trouble after giving Postgres more RAM, use the vmstat command.
You can use this command like "vmstat 10". (ignore the first line)
Keep an eye on the "pi" and "po" parameters. (kilobytes paged in and out)

HTH,

Matt
------
Matt Casters <matt.casters@ibridge.be>
i-Bridge bvba, http://www.kettle.be
Fonteinstraat 70, 9400 Okegem, Belgium
Phone +32 (0) 486/97.29.37


Re: Swapping on Solaris

От
Alan Stange
Дата:
Mark Kirkwood wrote:

> Kevin Schroeder wrote:
>
>>
>>
>> Ignoring the fact that the sort and vacuum numbers are really high,
>> this is what Solaris shows me when running top:
>>
>> Memory: 2048M real, 1376M free, 491M swap in use, 2955M swap free
>>
> Maybe check the swap usage with 'swap -l' which reports reliably if any
> (device or file) swap is actually used.
>
> I think Solaris 'top' does some strange accounting to calculate the
> 'swap in use' value (like including used memory).
>
> It looks to me like you are using no (device or file) swap at all, and
> have 1.3G of real memory free, so could in fact give Postgres more of
> it :-)

I suspect that "free" memory is in fact being used for the file system
cache.   There were some changes in the meaning of "free" in Solaris 8
and 9.   The memstat command gives a nice picture of memory usage on the
system.   I don't think memstat came with Solaris 8, but you can get it
from solarisinternals.com.   The Solaris Internals book is an excellent
read as well; it explains all of this in gory detail.

Note that files in /tmp are usually in a tmpfs file system.   These
files may be the usage of swap that you're seeing (as they will be paged
out on an active system with some memory pressure)

Finally, just as everyone suggests upgrading to newer postgresql
releases, you probably want to get to a newer Solaris release.

-- Alan

Re: Swapping on Solaris

От
"Kevin Schroeder"
Дата:
po and pi are relatively low, but do pick up when there's an increase in
activity.  I am seeing a lot of "minor faults", though.  vmstat -S 5 reports

 [9:38am]# vmstat -S 5
 procs     memory            page            disk          faults      cpu
 r b w   swap  free  si  so pi po fr de sr s0 s1 s3 --   in   sy   cs us sy
id
 0 0 0 3235616 1414536 0  0 303 11 10 0  0  6 24  0  0   13  192  461 17 11
72
 1 0 0 3004376 1274912 0  0  0  0  0  0  0  3 16  0  0  494 1147  441 52 25
23

494 in faults
1147 sy faults

Generally faults are a bad thing.  Is that the case here?

Kevin

----- Original Message -----
From: "Matt Casters" <Matt.Casters@advalvas.be>
To: <pgsql-performance@postgresql.org>
Sent: Wednesday, January 19, 2005 3:57 AM
Subject: Re: [PERFORM] Swapping on Solaris



> Kevin Schroeder wrote:
> It looks to me like you are using no (device or file) swap at all, and
> have 1.3G of real memory free, so could in fact give Postgres more of it
> :-)
>

Indeed.
If you DO run into trouble after giving Postgres more RAM, use the vmstat
command.
You can use this command like "vmstat 10". (ignore the first line)
Keep an eye on the "pi" and "po" parameters. (kilobytes paged in and out)

HTH,

Matt
------
Matt Casters <matt.casters@ibridge.be>
i-Bridge bvba, http://www.kettle.be
Fonteinstraat 70, 9400 Okegem, Belgium
Phone +32 (0) 486/97.29.37


---------------------------(end of broadcast)---------------------------
TIP 2: you can get off all lists at once with the unregister command
    (send "unregister YourEmailAddressHere" to majordomo@postgresql.org)




Re: Swapping on Solaris

От
"Kevin Schroeder"
Дата:
I take that back.  There actually is some paging going on.  I ran sar -g 5
10 and when a request was made (totally about 10 DB queries) my pgout/s
jumped to 5.8 and my ppgout/s jumped to 121.8.  pgfree/s also jumped to
121.80.

Kevin

----- Original Message -----
From: "Matt Casters" <Matt.Casters@advalvas.be>
To: <pgsql-performance@postgresql.org>
Sent: Wednesday, January 19, 2005 3:57 AM
Subject: Re: [PERFORM] Swapping on Solaris



> Kevin Schroeder wrote:
> It looks to me like you are using no (device or file) swap at all, and
> have 1.3G of real memory free, so could in fact give Postgres more of it
> :-)
>

Indeed.
If you DO run into trouble after giving Postgres more RAM, use the vmstat
command.
You can use this command like "vmstat 10". (ignore the first line)
Keep an eye on the "pi" and "po" parameters. (kilobytes paged in and out)

HTH,

Matt
------
Matt Casters <matt.casters@ibridge.be>
i-Bridge bvba, http://www.kettle.be
Fonteinstraat 70, 9400 Okegem, Belgium
Phone +32 (0) 486/97.29.37


---------------------------(end of broadcast)---------------------------
TIP 2: you can get off all lists at once with the unregister command
    (send "unregister YourEmailAddressHere" to majordomo@postgresql.org)




Re: Swapping on Solaris

От
"Kevin Schroeder"
Дата:
I suspect that the memory is being used to cache files as well since the
email boxes are using unix mailboxes, for the time being.  With people
checking their email sometimes once per minute I can see why Solaris would
want to cache those files.  Perhaps my question would be more appropriate to
a Solaris mailing list since what I really want to do is get Solaris to
simply allow PostgreSQL to use more RAM and reduce the amount of RAM used
for file caching.  I would have thought that Solaris gives some deference to
a running application that's being swapped than for a file cache.

Is there any way to set custom parameters on Solaris' file-caching behavior
to allow PostgreSQL to use more physical RAM?

I will also check out memstat.  It's not on my system, but I'll get it from
the site you noted.

Thanks
Kevin


----- Original Message -----
From: "Alan Stange" <stange@rentec.com>
Cc: "Kevin Schroeder" <kschroeder@mirageworks.com>;
<pgsql-performance@postgresql.org>
Sent: Wednesday, January 19, 2005 7:51 AM
Subject: Re: [PERFORM] Swapping on Solaris


> Mark Kirkwood wrote:
>
>> Kevin Schroeder wrote:
>>
>>>
>>>
>>> Ignoring the fact that the sort and vacuum numbers are really high, this
>>> is what Solaris shows me when running top:
>>>
>>> Memory: 2048M real, 1376M free, 491M swap in use, 2955M swap free
>>>
>> Maybe check the swap usage with 'swap -l' which reports reliably if any
>> (device or file) swap is actually used.
>>
>> I think Solaris 'top' does some strange accounting to calculate the
>> 'swap in use' value (like including used memory).
>>
>> It looks to me like you are using no (device or file) swap at all, and
>> have 1.3G of real memory free, so could in fact give Postgres more of it
>> :-)
>
> I suspect that "free" memory is in fact being used for the file system
> cache.   There were some changes in the meaning of "free" in Solaris 8 and
> 9.   The memstat command gives a nice picture of memory usage on the
> system.   I don't think memstat came with Solaris 8, but you can get it
> from solarisinternals.com.   The Solaris Internals book is an excellent
> read as well; it explains all of this in gory detail.
> Note that files in /tmp are usually in a tmpfs file system.   These files
> may be the usage of swap that you're seeing (as they will be paged out on
> an active system with some memory pressure)
>
> Finally, just as everyone suggests upgrading to newer postgresql releases,
> you probably want to get to a newer Solaris release.
> -- Alan
>
>
>


Re: Swapping on Solaris

От
"Kevin Schroeder"
Дата:
/tmp doesn't seem to be much of a problem.  I have about 1k worth of data in
there and 72k in /var/tmp.

Would turning swap off help in tuning the database in this regard?  top is
reporting that there's 1.25GB of RAM free on a 2GB system so, in my
estimation, there's no need for PostgreSQL to be swapped unless that free
memory is Solaris caching files in RAM.

Kevin


----- Original Message -----
From: "Greg Spiegelberg" <gspiegelberg@cranel.com>
To: <stange@rentec.com>
Cc: "Kevin Schroeder" <kschroeder@mirageworks.com>;
<pgsql-performance@postgresql.org>
Sent: Wednesday, January 19, 2005 9:07 AM
Subject: Re: [PERFORM] Swapping on Solaris


> Alan Stange wrote:
>>
>> Note that files in /tmp are usually in a tmpfs file system.   These files
>> may be the usage of swap that you're seeing (as they will be paged out on
>> an active system with some memory pressure)
>
> You can do a couple things with /tmp.  Create a separate file system
> for it so it will have zero impact on swap and use the "noatime" mount
> option.  Alternatively, limit the size of /tmp using the mount option
> "size=MBm" replacing "MB" with the size you want it to be in MBytes.  If
> your application uses /tmp heavily, be sure to put it on a speedy,
> local LUN.
>
>
>> Finally, just as everyone suggests upgrading to newer postgresql
>> releases, you probably want to get to a newer Solaris release.
>
> If you really want to avoid swapping I'd suggest tuning your database
> first with swap turned off and put it under a "normal" load while
> watching both top and vmstat.  When you're happy with it, turn swap
> back on for those "heavy" load times and move on.
>
> Greg
>
> --
> Greg Spiegelberg
>  Product Development Manager
>  Cranel, Incorporated.
>  Phone: 614.318.4314
>  Fax:   614.431.8388
>  Email: gspiegelberg@cranel.com
> Technology. Integrity. Focus.
>
>
>
>


Re: Swapping on Solaris

От
Alan Stange
Дата:
Kevin Schroeder wrote:

> I suspect that the memory is being used to cache files as well since
> the email boxes are using unix mailboxes, for the time being.  With
> people checking their email sometimes once per minute I can see why
> Solaris would want to cache those files.  Perhaps my question would be
> more appropriate to a Solaris mailing list since what I really want to
> do is get Solaris to simply allow PostgreSQL to use more RAM and
> reduce the amount of RAM used for file caching.  I would have thought
> that Solaris gives some deference to a running application that's
> being swapped than for a file cache.
>
> Is there any way to set custom parameters on Solaris' file-caching
> behavior to allow PostgreSQL to use more physical RAM?

Your explanation doesn't sound quite correct.   If postgresql malloc()'s
some memory and uses it, the file cache will be reduced in size and the
memory given to postgresql.   But if postgresql doesn't ask for or use
the memory, then solaris is going to use it for something else.  There's
nothing in Solaris that doesn't "allow" postgresql to use more RAM.

-- Alan

Re: Swapping on Solaris

От
Greg Spiegelberg
Дата:
Alan Stange wrote:
>
> Note that files in /tmp are usually in a tmpfs file system.   These
> files may be the usage of swap that you're seeing (as they will be paged
> out on an active system with some memory pressure)

You can do a couple things with /tmp.  Create a separate file system
for it so it will have zero impact on swap and use the "noatime" mount
option.  Alternatively, limit the size of /tmp using the mount option
"size=MBm" replacing "MB" with the size you want it to be in MBytes.  If
your application uses /tmp heavily, be sure to put it on a speedy,
local LUN.


> Finally, just as everyone suggests upgrading to newer postgresql
> releases, you probably want to get to a newer Solaris release.

If you really want to avoid swapping I'd suggest tuning your database
first with swap turned off and put it under a "normal" load while
watching both top and vmstat.  When you're happy with it, turn swap
back on for those "heavy" load times and move on.

Greg

--
Greg Spiegelberg
  Product Development Manager
  Cranel, Incorporated.
  Phone: 614.318.4314
  Fax:   614.431.8388
  Email: gspiegelberg@cranel.com
Technology. Integrity. Focus.


Re: Swapping on Solaris

От
"Kevin Schroeder"
Дата:
Maybe, I'm just seeing a problem where none exists.  I ran sar -w 3 100 and
I actually did not see any swap activity despite the fact that I've got
500+MB of swap file being used.

Kevin

----- Original Message -----
From: "Alan Stange" <stange@rentec.com>
To: "Kevin Schroeder" <kschroeder@mirageworks.com>
Cc: <pgsql-performance@postgresql.org>
Sent: Wednesday, January 19, 2005 9:42 AM
Subject: Re: [PERFORM] Swapping on Solaris


> Kevin Schroeder wrote:
>
>> I take that back.  There actually is some paging going on.  I ran sar -g
>> 5 10 and when a request was made (totally about 10 DB queries) my pgout/s
>> jumped to 5.8 and my ppgout/s jumped to 121.8.  pgfree/s also jumped to
>> 121.80.
>
> I'm fairly sure that the pi and po numbers include file IO in Solaris,
> because of the unified VM and file systems.
>
> -- Alan
>
>
>


Re: Swapping on Solaris

От
Alan Stange
Дата:
Kevin Schroeder wrote:

> I take that back.  There actually is some paging going on.  I ran sar
> -g 5 10 and when a request was made (totally about 10 DB queries) my
> pgout/s jumped to 5.8 and my ppgout/s jumped to 121.8.  pgfree/s also
> jumped to 121.80.

I'm fairly sure that the pi and po numbers include file IO in Solaris,
because of the unified VM and file systems.

-- Alan

Re: Swapping on Solaris

От
"Kevin Schroeder"
Дата:
I may be asking the question the wrong way, but when I start up PostgreSQL
swap is what gets used the most of.  I've got 1282MB free RAM right now and
and 515MB swap in use.  Granted, swap file usage probably wouldn't be zero,
but I would guess that it should be a lot lower so something must be keeping
PostgreSQL from using the free RAM that my system is reporting.  For
example, one of my postgres processes is 201M in size but on 72M is resident
in RAM.  That extra 130M is available in RAM, according to top, but postgres
isn't using it.

Kevin

----- Original Message -----
From: "Alan Stange" <stange@rentec.com>
To: "Kevin Schroeder" <kschroeder@mirageworks.com>
Cc: <pgsql-performance@postgresql.org>
Sent: Wednesday, January 19, 2005 9:30 AM
Subject: Re: [PERFORM] Swapping on Solaris


> Kevin Schroeder wrote:
>
>> I suspect that the memory is being used to cache files as well since the
>> email boxes are using unix mailboxes, for the time being.  With people
>> checking their email sometimes once per minute I can see why Solaris
>> would want to cache those files.  Perhaps my question would be more
>> appropriate to a Solaris mailing list since what I really want to do is
>> get Solaris to simply allow PostgreSQL to use more RAM and reduce the
>> amount of RAM used for file caching.  I would have thought that Solaris
>> gives some deference to a running application that's being swapped than
>> for a file cache.
>>
>> Is there any way to set custom parameters on Solaris' file-caching
>> behavior to allow PostgreSQL to use more physical RAM?
>
> Your explanation doesn't sound quite correct.   If postgresql malloc()'s
> some memory and uses it, the file cache will be reduced in size and the
> memory given to postgresql.   But if postgresql doesn't ask for or use the
> memory, then solaris is going to use it for something else.  There's
> nothing in Solaris that doesn't "allow" postgresql to use more RAM.
>
> -- Alan
>
>
>


Re: Swapping on Solaris

От
Jeff
Дата:
On Jan 19, 2005, at 10:42 AM, Alan Stange wrote:

> Kevin Schroeder wrote:
>
>> I take that back.  There actually is some paging going on.  I ran sar
>> -g 5 10 and when a request was made (totally about 10 DB queries) my
>> pgout/s jumped to 5.8 and my ppgout/s jumped to 121.8.  pgfree/s also
>> jumped to 121.80.
>
> I'm fairly sure that the pi and po numbers include file IO in Solaris,
> because of the unified VM and file systems.

Curiously, what are your shared_buffers and sort_mem set too?
Perhaps they are too high?


--
Jeff Trout <jeff@jefftrout.com>
http://www.jefftrout.com/
http://www.stuarthamm.net/


Re: Swapping on Solaris

От
"Kevin Schroeder"
Дата:
I think it's probably just reserving them.  I can't think of anything else.
Also, when I run swap activity with sar I don't see any activity, which also
points to reserved swap space, not used swap space.

swap -s reports

total: 358336k bytes allocated + 181144k reserved = 539480k used, 2988840k
available

Kevin

----- Original Message -----
From: "Alan Stange" <stange@rentec.com>
To: "Kevin Schroeder" <kschroeder@mirageworks.com>
Cc: <pgsql-performance@postgresql.org>
Sent: Wednesday, January 19, 2005 11:04 AM
Subject: Re: [PERFORM] Swapping on Solaris


> Kevin Schroeder wrote:
>
>> I may be asking the question the wrong way, but when I start up
>> PostgreSQL swap is what gets used the most of.  I've got 1282MB free RAM
>> right now and and 515MB swap in use.  Granted, swap file usage probably
>> wouldn't be zero, but I would guess that it should be a lot lower so
>> something must be keeping PostgreSQL from using the free RAM that my
>> system is reporting.  For example, one of my postgres processes is 201M
>> in size but on 72M is resident in RAM.  That extra 130M is available in
>> RAM, according to top, but postgres isn't using it.
>
> The test you're doing doesn't measure what you think you're measuring.
>
> First, what else is running on the machine?    Note that some shared
> memory allocations do reserve backing pages in swap, even though the pages
> aren't currently in use.  Perhaps this is what you're measuring?
>  "swap -s" has better numbers than top.
>
> You'd be better by trying a reboot then starting pgsql and seeing what
> memory is used.
>
> Just because you start a process and see the swap number increase doesn't
> mean that the new process is in swap.  It means some anonymous pages had
> to be evicted to swap to make room for the new process or some pages had
> to be reserved in swap for future use.   Typically a new process won't be
> paged out unless something else is causing enormous memory pressure...
>
> -- Alan
>
>
>


Re: Swapping on Solaris

От
Alan Stange
Дата:
Kevin Schroeder wrote:

> I may be asking the question the wrong way, but when I start up
> PostgreSQL swap is what gets used the most of.  I've got 1282MB free
> RAM right now and and 515MB swap in use.  Granted, swap file usage
> probably wouldn't be zero, but I would guess that it should be a lot
> lower so something must be keeping PostgreSQL from using the free RAM
> that my system is reporting.  For example, one of my postgres
> processes is 201M in size but on 72M is resident in RAM.  That extra
> 130M is available in RAM, according to top, but postgres isn't using it.

The test you're doing doesn't measure what you think you're measuring.

First, what else is running on the machine?    Note that some shared
memory allocations do reserve backing pages in swap, even though the
pages aren't currently in use.  Perhaps this is what you're measuring?
"swap -s" has better numbers than top.

You'd be better by trying a reboot then starting pgsql and seeing what
memory is used.

Just because you start a process and see the swap number increase
doesn't mean that the new process is in swap.  It means some anonymous
pages had to be evicted to swap to make room for the new process or some
pages had to be reserved in swap for future use.   Typically a new
process won't be paged out unless something else is causing enormous
memory pressure...

-- Alan

Re: Swapping on Solaris

От
Jeff
Дата:
On Jan 19, 2005, at 10:40 AM, Kevin Schroeder wrote:

> I may be asking the question the wrong way, but when I start up
> PostgreSQL swap is what gets used the most of.  I've got 1282MB free
> RAM right now and and 515MB swap in use.  Granted, swap file usage
> probably wouldn't be zero, but I would guess that it should be a lot
> lower so something must be keeping PostgreSQL from using the free RAM
> that my system is reporting.  For example, one of my postgres
> processes is 201M in size but on 72M is resident in RAM.  That extra
> 130M is available in RAM, according to top, but postgres isn't using
> it.

Can you please give us your exact shared_buffer and sort_mem settings?
This will help greatly.  As a general thing, we say don't use more than
10k shared bufs unless you have done testing and enjoy a benefit.
Managing all those buffers isn't free.

I'm also not sure how Solaris reports shared memory usage for apps... a
lot of that could be shared mem.

Can you watch say, vmstat 1 for a minute or two while PG is running and
see if you're actually swapping?

--
Jeff Trout <jeff@jefftrout.com>
http://www.jefftrout.com/
http://www.stuarthamm.net/


Re: Swapping on Solaris

От
Matt Clark
Дата:
This page may be of use:

http://www.serverworldmagazine.com/monthly/2003/02/solaris.shtml

 From personal experience, for god's sake don't think Solaris' VM/swap
implementation is easy - it's damn good, but it ain't easy!

Matt

Kevin Schroeder wrote:

> I think it's probably just reserving them.  I can't think of anything
> else. Also, when I run swap activity with sar I don't see any
> activity, which also points to reserved swap space, not used swap space.
>
> swap -s reports
>
> total: 358336k bytes allocated + 181144k reserved = 539480k used,
> 2988840k available
>
> Kevin
>
> ----- Original Message ----- From: "Alan Stange" <stange@rentec.com>
> To: "Kevin Schroeder" <kschroeder@mirageworks.com>
> Cc: <pgsql-performance@postgresql.org>
> Sent: Wednesday, January 19, 2005 11:04 AM
> Subject: Re: [PERFORM] Swapping on Solaris
>
>
>> Kevin Schroeder wrote:
>>
>>> I may be asking the question the wrong way, but when I start up
>>> PostgreSQL swap is what gets used the most of.  I've got 1282MB free
>>> RAM right now and and 515MB swap in use.  Granted, swap file usage
>>> probably wouldn't be zero, but I would guess that it should be a lot
>>> lower so something must be keeping PostgreSQL from using the free
>>> RAM that my system is reporting.  For example, one of my postgres
>>> processes is 201M in size but on 72M is resident in RAM.  That extra
>>> 130M is available in RAM, according to top, but postgres isn't using
>>> it.
>>
>>
>> The test you're doing doesn't measure what you think you're measuring.
>>
>> First, what else is running on the machine?    Note that some shared
>> memory allocations do reserve backing pages in swap, even though the
>> pages aren't currently in use.  Perhaps this is what you're
>> measuring?  "swap -s" has better numbers than top.
>>
>> You'd be better by trying a reboot then starting pgsql and seeing
>> what memory is used.
>>
>> Just because you start a process and see the swap number increase
>> doesn't mean that the new process is in swap.  It means some
>> anonymous pages had to be evicted to swap to make room for the new
>> process or some pages had to be reserved in swap for future use.
>> Typically a new process won't be paged out unless something else is
>> causing enormous memory pressure...
>>
>> -- Alan
>>
>>
>>
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 3: if posting/reading through Usenet, please send an appropriate
>      subscribe-nomail command to majordomo@postgresql.org so that your
>      message can get through to the mailing list cleanly


Re: Swapping on Solaris

От
"Kevin Schroeder"
Дата:
Well, easy it ain't and I believe it's good.  One final question:  When I
run sar -w I get no swap activity, but the process switch column registers
between 400 and 700 switches per second.  Would that be in the normal range
for a medium-use system?

Thanks
Kevin

----- Original Message -----
From: "Matt Clark" <matt@ymogen.net>
To: "Kevin Schroeder" <kschroeder@mirageworks.com>
Cc: <pgsql-performance@postgresql.org>
Sent: Wednesday, January 19, 2005 1:01 PM
Subject: Re: [PERFORM] Swapping on Solaris


> This page may be of use:
>
> http://www.serverworldmagazine.com/monthly/2003/02/solaris.shtml
>
> From personal experience, for god's sake don't think Solaris' VM/swap
> implementation is easy - it's damn good, but it ain't easy!
>
> Matt
>
> Kevin Schroeder wrote:
>
>> I think it's probably just reserving them.  I can't think of anything
>> else. Also, when I run swap activity with sar I don't see any activity,
>> which also points to reserved swap space, not used swap space.
>>
>> swap -s reports
>>
>> total: 358336k bytes allocated + 181144k reserved = 539480k used,
>> 2988840k available
>>
>> Kevin
>>
>> ----- Original Message ----- From: "Alan Stange" <stange@rentec.com>
>> To: "Kevin Schroeder" <kschroeder@mirageworks.com>
>> Cc: <pgsql-performance@postgresql.org>
>> Sent: Wednesday, January 19, 2005 11:04 AM
>> Subject: Re: [PERFORM] Swapping on Solaris
>>
>>
>>> Kevin Schroeder wrote:
>>>
>>>> I may be asking the question the wrong way, but when I start up
>>>> PostgreSQL swap is what gets used the most of.  I've got 1282MB free
>>>> RAM right now and and 515MB swap in use.  Granted, swap file usage
>>>> probably wouldn't be zero, but I would guess that it should be a lot
>>>> lower so something must be keeping PostgreSQL from using the free RAM
>>>> that my system is reporting.  For example, one of my postgres processes
>>>> is 201M in size but on 72M is resident in RAM.  That extra 130M is
>>>> available in RAM, according to top, but postgres isn't using it.
>>>
>>>
>>> The test you're doing doesn't measure what you think you're measuring.
>>>
>>> First, what else is running on the machine?    Note that some shared
>>> memory allocations do reserve backing pages in swap, even though the
>>> pages aren't currently in use.  Perhaps this is what you're measuring?
>>> "swap -s" has better numbers than top.
>>>
>>> You'd be better by trying a reboot then starting pgsql and seeing what
>>> memory is used.
>>>
>>> Just because you start a process and see the swap number increase
>>> doesn't mean that the new process is in swap.  It means some anonymous
>>> pages had to be evicted to swap to make room for the new process or some
>>> pages had to be reserved in swap for future use.   Typically a new
>>> process won't be paged out unless something else is causing enormous
>>> memory pressure...
>>>
>>> -- Alan
>>>
>>>
>>>
>>
>>
>> ---------------------------(end of broadcast)---------------------------
>> TIP 3: if posting/reading through Usenet, please send an appropriate
>>      subscribe-nomail command to majordomo@postgresql.org so that your
>>      message can get through to the mailing list cleanly
>
>
>
>


Re: Swapping on Solaris

От
Simon Riggs
Дата:
On Wed, 2005-01-19 at 09:40 -0600, Kevin Schroeder wrote:
> I may be asking the question the wrong way, but when I start up PostgreSQL
> swap is what gets used the most of.  I've got 1282MB free RAM right now and
> and 515MB swap in use.  Granted, swap file usage probably wouldn't be zero,
> but I would guess that it should be a lot lower so something must be keeping
> PostgreSQL from using the free RAM that my system is reporting.  For
> example, one of my postgres processes is 201M in size but on 72M is resident
> in RAM.  That extra 130M is available in RAM, according to top, but postgres
> isn't using it.

You probably need to look at the way Solaris memory allocation works.

On Linux 2.6, my understanding is that if a process allocates memory,
but doesn't actually use it, then the OS is smart enough to swap the
overallocated portion out to swap. The effect of that is that the
program stays happy because it has all the "memory" it thinks it needs,
while the OS is happy because it conserves it valuable physical RAM for
memory that is actually being used.

If what I say is correct, you should actually observe very low swapping
I/O rates on the system.

Anyway, look at how the algorithms work if you are worried by what you
see. But mostly, if the system is performing OK, then no need to worry -
if your only measure of that is system performance data then you need to
instrument your application better, so you can look at the data that
really matters.

--
Best Regards, Simon Riggs


Re: Swapping on Solaris

От
Andrew Sullivan
Дата:
On Wed, Jan 19, 2005 at 10:42:26AM -0500, Alan Stange wrote:
>
> I'm fairly sure that the pi and po numbers include file IO in Solaris,
> because of the unified VM and file systems.

That's correct.

A

--
Andrew Sullivan  | ajs@crankycanuck.ca
When my information changes, I alter my conclusions.  What do you do sir?
        --attr. John Maynard Keynes

Re: Swapping on Solaris

От
Bruce Momjian
Дата:
Andrew Sullivan wrote:
> On Wed, Jan 19, 2005 at 10:42:26AM -0500, Alan Stange wrote:
> >
> > I'm fairly sure that the pi and po numbers include file IO in Solaris,
> > because of the unified VM and file systems.
>
> That's correct.

I have seen cases on BSDs where 'pi' includes page-faulting in the
executables from the file system, but Solaris actually has 'po' as
filesystem I/O.  That is a new one to me.

--
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 359-1001
  +  If your life is a hard drive,     |  13 Roberts Road
  +  Christ can be your backup.        |  Newtown Square, Pennsylvania 19073