Memory question

Lists: pgsql-performance
From: "Patrick Hatcher" <PHatcher(at)macys(dot)com>
To: pgsql-performance(at)postgresql(dot)org
Subject: Memory question
Date: 2003-06-27 19:09:50
Message-ID: OFDDA6A696.3FAB98BA-ON88256D52.006707EF-88256D52.0069C75F@fds.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-performance

Sorry for posting an obvious Linux question, but have any of you
encountered this and how have you fixed it.
I have 6gig Ram box. I've set my shmmax to 3072000000. The database
starts up fine without any issues. As soon as a query is ran
or a FTP process to the server is done, the used memory shoots up and
appears to never be released.
My fear is that this may cause problems for my database if this number
continues to grow. Below is my TOP after running a query, and shutting
down PgAdmin. While not low now, the amount of free memory has dropped to
around 11mg. I'll admit I'm not that Linux savvy, but am I reading this
correct?

--TOP

45 processes: 44 sleeping, 1 running, 0 zombie, 0 stopped
CPU0 states: 0.0% user, 0.0% system, 0.0% nice, 100.0% idle
CPU1 states: 0.0% user, 0.0% system, 0.0% nice, 100.0% idle
CPU2 states: 0.0% user, 0.0% system, 0.0% nice, 100.0% idle
CPU3 states: 0.0% user, 0.0% system, 0.0% nice, 100.0% idle
Mem: 6711564K av, 6517776K used, 193788K free, 0K shrd, 25168K
buff
Swap: 2044056K av, 0K used, 2044056K free 6257620K
cached

Patrick Hatcher


From: "scott(dot)marlowe" <scott(dot)marlowe(at)ihs(dot)com>
To: Patrick Hatcher <PHatcher(at)macys(dot)com>
Cc: <pgsql-performance(at)postgresql(dot)org>
Subject: Re: Memory question
Date: 2003-06-27 19:44:38
Message-ID: Pine.LNX.4.33.0306271341590.964-100000@css120.ihs.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-performance

This is actually normal. Look at the amount cached: 6257620K. That's
6.2Gig of cache. Linux is using only 6517776k - 6257620k of memory, the
rest is just acting as kernel cache. If anything tries to allocate a bit
of memory, linux will flush enough cache to give the memory to the
application that needs it.

Note that you're only showing linux and all its applications using about
256Meg.

On Fri, 27 Jun 2003, Patrick Hatcher wrote:

> Sorry for posting an obvious Linux question, but have any of you
> encountered this and how have you fixed it.
> I have 6gig Ram box. I've set my shmmax to 3072000000. The database
> starts up fine without any issues. As soon as a query is ran
> or a FTP process to the server is done, the used memory shoots up and
> appears to never be released.
> My fear is that this may cause problems for my database if this number
> continues to grow. Below is my TOP after running a query, and shutting
> down PgAdmin. While not low now, the amount of free memory has dropped to
> around 11mg. I'll admit I'm not that Linux savvy, but am I reading this
> correct?
>
> --TOP
>
> 45 processes: 44 sleeping, 1 running, 0 zombie, 0 stopped
> CPU0 states: 0.0% user, 0.0% system, 0.0% nice, 100.0% idle
> CPU1 states: 0.0% user, 0.0% system, 0.0% nice, 100.0% idle
> CPU2 states: 0.0% user, 0.0% system, 0.0% nice, 100.0% idle
> CPU3 states: 0.0% user, 0.0% system, 0.0% nice, 100.0% idle
> Mem: 6711564K av, 6517776K used, 193788K free, 0K shrd, 25168K
> buff
> Swap: 2044056K av, 0K used, 2044056K free 6257620K
> cached
>
> Patrick Hatcher
>
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 7: don't forget to increase your free space map settings
>


From: Josh Berkus <josh(at)agliodbs(dot)com>
To: "Patrick Hatcher" <PHatcher(at)macys(dot)com>, pgsql-performance(at)postgresql(dot)org
Subject: Re: Memory question
Date: 2003-06-27 19:54:51
Message-ID: 200306271254.51441.josh@agliodbs.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-performance

Patrick,

> Sorry for posting an obvious Linux question, but have any of you
> encountered this and how have you fixed it.
> I have 6gig Ram box. I've set my shmmax to 3072000000. The database
> starts up fine without any issues. As soon as a query is ran
> or a FTP process to the server is done, the used memory shoots up and
> appears to never be released.

What's you shared_buffers set to after our talk? Do you actually need 3gb of
shmmax?

> My fear is that this may cause problems for my database if this number
> continues to grow. Below is my TOP after running a query, and shutting
> down PgAdmin. While not low now, the amount of free memory has dropped to
> around 11mg. I'll admit I'm not that Linux savvy, but am I reading this
> correct?

No.

> Mem: 6711564K av, 6517776K used, 193788K free, 0K shrd, 25168K

The "used" figure in Top doesn't really tell you anything, since it includes
the kernel buffer which tries to take up all available memory. If you
actually look at the list of processes, I think you'll find that you're only
using 1-2% of memory for applications.

I'm not sure what app would show your "real" free memory.

--
-Josh Berkus
Aglio Database Solutions
San Francisco


From: "Patrick Hatcher" <PHatcher(at)macys(dot)com>
To: josh(at)agliodbs(dot)com
Cc: pgsql-performance(at)postgresql(dot)org
Subject: Re: Memory question
Date: 2003-06-27 19:58:22
Message-ID: OF52DB8C06.78DFD2FC-ON88256D52.006D26E1-88256D52.006E391A@fds.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-performance


Shared buffer is now set to 20,000 as suggested. So far so good.
As far as shmmax, it really is my ignorance of Linux. We are going to play
around with this number. Is there a suggested amount since I have
my effective_cache_size = 625000 (or does one have nothing to do with the
other)
Thanks again

Patrick Hatcher


Josh Berkus
<josh(at)agliodbs To: "Patrick Hatcher" <PHatcher(at)macys(dot)com>, pgsql-performance(at)postgresql(dot)org
.com> cc:
Subject: Re: [PERFORM] Memory question
06/27/2003
12:54 PM
Please respond
to josh

Patrick,

> Sorry for posting an obvious Linux question, but have any of you
> encountered this and how have you fixed it.
> I have 6gig Ram box. I've set my shmmax to 3072000000. The database
> starts up fine without any issues. As soon as a query is ran
> or a FTP process to the server is done, the used memory shoots up and
> appears to never be released.

What's you shared_buffers set to after our talk? Do you actually need 3gb
of
shmmax?

> My fear is that this may cause problems for my database if this number
> continues to grow. Below is my TOP after running a query, and shutting
> down PgAdmin. While not low now, the amount of free memory has dropped
to
> around 11mg. I'll admit I'm not that Linux savvy, but am I reading this
> correct?

No.

> Mem: 6711564K av, 6517776K used, 193788K free, 0K shrd, 25168K

The "used" figure in Top doesn't really tell you anything, since it
includes
the kernel buffer which tries to take up all available memory. If you
actually look at the list of processes, I think you'll find that you're
only
using 1-2% of memory for applications.

I'm not sure what app would show your "real" free memory.

--
-Josh Berkus
Aglio Database Solutions
San Francisco


From: "Patrick Hatcher" <PHatcher(at)macys(dot)com>
To: scott(dot)marlowe(at)ihs(dot)com
Cc: pgsql-performance(at)postgresql(dot)org
Subject: Re: Memory question
Date: 2003-06-27 19:59:23
Message-ID: OFF9755952.AD6D7C3D-ON88256D52.006DC794-88256D52.006E50C8@fds.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-performance


Thank you

Patrick Hatcher


"scott.marlowe
" To: Patrick Hatcher <PHatcher(at)macys(dot)com>
<scott.marlowe cc: <pgsql-performance(at)postgresql(dot)org>
@ihs.com> Subject: Re: [PERFORM] Memory question

06/27/2003
12:44 PM

This is actually normal. Look at the amount cached: 6257620K. That's
6.2Gig of cache. Linux is using only 6517776k - 6257620k of memory, the
rest is just acting as kernel cache. If anything tries to allocate a bit
of memory, linux will flush enough cache to give the memory to the
application that needs it.

Note that you're only showing linux and all its applications using about
256Meg.

On Fri, 27 Jun 2003, Patrick Hatcher wrote:

> Sorry for posting an obvious Linux question, but have any of you
> encountered this and how have you fixed it.
> I have 6gig Ram box. I've set my shmmax to 3072000000. The database
> starts up fine without any issues. As soon as a query is ran
> or a FTP process to the server is done, the used memory shoots up and
> appears to never be released.
> My fear is that this may cause problems for my database if this number
> continues to grow. Below is my TOP after running a query, and shutting
> down PgAdmin. While not low now, the amount of free memory has dropped
to
> around 11mg. I'll admit I'm not that Linux savvy, but am I reading this
> correct?
>
> --TOP
>
> 45 processes: 44 sleeping, 1 running, 0 zombie, 0 stopped
> CPU0 states: 0.0% user, 0.0% system, 0.0% nice, 100.0% idle
> CPU1 states: 0.0% user, 0.0% system, 0.0% nice, 100.0% idle
> CPU2 states: 0.0% user, 0.0% system, 0.0% nice, 100.0% idle
> CPU3 states: 0.0% user, 0.0% system, 0.0% nice, 100.0% idle
> Mem: 6711564K av, 6517776K used, 193788K free, 0K shrd, 25168K
> buff
> Swap: 2044056K av, 0K used, 2044056K free 6257620K
> cached
>
> Patrick Hatcher
>
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 7: don't forget to increase your free space map settings
>


From: Jord Tanner <jord(at)indygecko(dot)com>
To: Patrick Hatcher <PHatcher(at)macys(dot)com>, pgsql-performance(at)postgresql(dot)org
Subject: Re: Memory question
Date: 2003-06-27 20:17:04
Message-ID: 1056745023.4726.50.camel@gecko
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-performance

On Fri, 2003-06-27 at 12:09, Patrick Hatcher wrote:

> I have 6gig Ram box. I've set my shmmax to 3072000000. The database
> starts up fine without any issues. As soon as a query is ran
> or a FTP process to the server is done, the used memory shoots up and
> appears to never be released.

In my experience Linux likes to allocate almost all available RAM. I've
never had any trouble with that. I'm looking at the memory meter on my
RH9 development workstation and it is at 95%. Performance is good, so I
just trust that the kernel knows what it is doing.

> Mem: 6711564K av, 6517776K used, 193788K free, 0K shrd, 25168K
> buff
> Swap: 2044056K av, 0K used, 2044056K free 6257620K
> cached

I've heard anecdotally that Linux has troubles if the swap space is less
than the RAM size. I note that you have 6G of RAM, but only 2G of swap.

I'm sure others on the list will have more definitive opinions.

--
Jord Tanner <jord(at)indygecko(dot)com>


From: Matthew Hixson <hixson(at)poindextrose(dot)org>
To: pgsql-performance(at)postgresql(dot)org
Subject: Re: Memory question
Date: 2003-06-27 20:30:28
Message-ID: 30A40B16-A8DE-11D7-81EC-000393669C1A@poindextrose.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-performance

On Friday, June 27, 2003, at 01:17 PM, Jord Tanner wrote:

> On Fri, 2003-06-27 at 12:09, Patrick Hatcher wrote:
>
>
>
>> I have 6gig Ram box. I've set my shmmax to 3072000000. The database
>> starts up fine without any issues. As soon as a query is ran
>> or a FTP process to the server is done, the used memory shoots up and
>> appears to never be released.
>
> In my experience Linux likes to allocate almost all available RAM. I've
> never had any trouble with that. I'm looking at the memory meter on my
> RH9 development workstation and it is at 95%. Performance is good, so I
> just trust that the kernel knows what it is doing.
>
>
>
>> Mem: 6711564K av, 6517776K used, 193788K free, 0K shrd,
>> 25168K
>> buff
>> Swap: 2044056K av, 0K used, 2044056K free
>> 6257620K
>> cached
>
> I've heard anecdotally that Linux has troubles if the swap space is
> less
> than the RAM size. I note that you have 6G of RAM, but only 2G of swap.

I've heard that too, but it doesn't seem to make much sense to me. If
you get to the point where your machine is _needing_ 2GB of swap then
something has gone horribly wrong (or you just need more RAM in the
machine) and it will just crawl until the kernel kills off whatever
process causes the swap space to be exceeded. Seems to me that you
should only have that much swap if you can't afford more RAM or you've
tapped out your machine's capacity, and your application needs that
much memory.
-M@


From: "Arjen van der Meijden" <acm(at)tweakers(dot)net>
To: <josh(at)agliodbs(dot)com>, "'Patrick Hatcher'" <PHatcher(at)macys(dot)com>, <pgsql-performance(at)postgresql(dot)org>
Subject: Re: Memory question
Date: 2003-06-27 20:49:17
Message-ID: 004901c33ced$98cf6430$3ac15e91@acm
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-performance

> The "used" figure in Top doesn't really tell you anything,
> since it includes
> the kernel buffer which tries to take up all available
> memory. If you
> actually look at the list of processes, I think you'll find
> that you're only
> using 1-2% of memory for applications.
>
> I'm not sure what app would show your "real" free memory.

The command 'free' shows what you like to know:
$ free
total used free shared buffers
cached
Mem: 1551480 1505656 45824 0 101400
1015540
-/+ buffers/cache: 388716 1162764
Swap: 524264 23088 501176

The used/free amounts on the second line are the interesting ones in
this case.

Arjen


From: "scott(dot)marlowe" <scott(dot)marlowe(at)ihs(dot)com>
To: Matthew Hixson <hixson(at)poindextrose(dot)org>
Cc: <pgsql-performance(at)postgresql(dot)org>
Subject: Re: Memory question
Date: 2003-06-27 20:51:25
Message-ID: Pine.LNX.4.33.0306271450260.964-100000@css120.ihs.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-performance

On Fri, 27 Jun 2003, Matthew Hixson wrote:

> On Friday, June 27, 2003, at 01:17 PM, Jord Tanner wrote:
> > I've heard anecdotally that Linux has troubles if the swap space is
> > less
> > than the RAM size. I note that you have 6G of RAM, but only 2G of swap.
>
> I've heard that too, but it doesn't seem to make much sense to me. If
> you get to the point where your machine is _needing_ 2GB of swap then
> something has gone horribly wrong (or you just need more RAM in the
> machine) and it will just crawl until the kernel kills off whatever
> process causes the swap space to be exceeded. Seems to me that you
> should only have that much swap if you can't afford more RAM or you've
> tapped out your machine's capacity, and your application needs that
> much memory.

This was an artifact in older kernels where the swap code didn't work
right unless it had as much swap as memory. I'm pretty sure that was
fixed long ago in the 2.4 series.


From: "Arjen van der Meijden" <acm(at)tweakers(dot)net>
To: "'Matthew Hixson'" <hixson(at)poindextrose(dot)org>, <pgsql-performance(at)postgresql(dot)org>
Subject: Re: Memory question
Date: 2003-06-27 20:55:40
Message-ID: 004b01c33cee$7e6b2560$3ac15e91@acm
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-performance

> I've heard that too, but it doesn't seem to make much sense
> to me. If
> you get to the point where your machine is _needing_ 2GB of swap then
> something has gone horribly wrong (or you just need more RAM in the
> machine) and it will just crawl until the kernel kills off whatever
> process causes the swap space to be exceeded. Seems to me that you
> should only have that much swap if you can't afford more RAM
> or you've
> tapped out your machine's capacity, and your application needs that
> much memory.
> -M@
I've heard the same, the reason behind it was that there needs to be
one-to-one copy of the memory to be able to swap out everything and to
have a gain in the total "memory", you'd need twice as much swap as
memory to have a doubling of your memory.

But afaik this behaviour has been adjusted since the 2.4.5 kernel and
isn't a real issue anymore.

Please keep in mind that I'm no expert at all on linux, so if you want
to be sure, you'd better mail to the kernel-mailinglist orso :)

Anyway, I manage a few machines with 1GB++ memory and none of them has
more than 1G of swap and none of them uses that swap for more than a few
MB unless something was terribly wrong, so the actual 'risk' probably
doesn't have a high chance to occur.

Arjen


From: Thomas Swan <tswan(at)idigx(dot)com>
To: Arjen van der Meijden <acm(at)tweakers(dot)net>
Cc: "'Matthew Hixson'" <hixson(at)poindextrose(dot)org>, pgsql-performance(at)postgresql(dot)org
Subject: Re: Memory question
Date: 2003-06-30 05:49:39
Message-ID: 3EFFCF73.8010801@idigx.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-performance

Arjen van der Meijden wrote:

>>I've heard that too, but it doesn't seem to make much sense
>>to me. If
>>you get to the point where your machine is _needing_ 2GB of swap then
>>something has gone horribly wrong (or you just need more RAM in the
>>machine) and it will just crawl until the kernel kills off whatever
>>process causes the swap space to be exceeded. Seems to me that you
>>should only have that much swap if you can't afford more RAM
>>or you've
>>tapped out your machine's capacity, and your application needs that
>>much memory.
>> -M@
>>
>>
>I've heard the same, the reason behind it was that there needs to be
>one-to-one copy of the memory to be able to swap out everything and to
>have a gain in the total "memory", you'd need twice as much swap as
>memory to have a doubling of your memory.
>
>But afaik this behaviour has been adjusted since the 2.4.5 kernel and
>isn't a real issue anymore.
>
It may be different in vendor released kernels as the default overcommit
behavior of the Linux kernel may vary. More detailed discussions can be
found on the LKML, or you can find some useful summaries by searching
through the last couple "Kernel Traffic" issues <http://kt.zork.net> ..
I had some unexpected problems on one system, an older RH distribution,
until I actually set the swap to be double the 2GB of ram on the system:
4GB.

>Please keep in mind that I'm no expert at all on linux, so if you want
>to be sure, you'd better mail to the kernel-mailinglist orso :)
>
>Anyway, I manage a few machines with 1GB++ memory and none of them has
>more than 1G of swap and none of them uses that swap for more than a few
>MB unless something was terribly wrong, so the actual 'risk' probably
>doesn't have a high chance to occur.
>
>Arjen
>
>
>
>
>---------------------------(end of broadcast)---------------------------
>TIP 5: Have you checked our extensive FAQ?
>
> http://www.postgresql.org/docs/faqs/FAQ.html
>
>


From: Jonathan Gardner <jgardner(at)jonathangardner(dot)net>
To: "scott(dot)marlowe" <scott(dot)marlowe(at)ihs(dot)com>, Patrick Hatcher <PHatcher(at)macys(dot)com>
Cc: <pgsql-performance(at)postgresql(dot)org>
Subject: Re: Memory question
Date: 2003-06-30 16:02:12
Message-ID: 200306300902.13161.jgardner@jonathangardner.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-performance

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Friday 27 June 2003 12:44, scott.marlowe wrote:
> This is actually normal. Look at the amount cached: 6257620K. That's
> 6.2Gig of cache. Linux is using only 6517776k - 6257620k of memory, the
> rest is just acting as kernel cache. If anything tries to allocate a bit
> of memory, linux will flush enough cache to give the memory to the
> application that needs it.
>

I think it is appropriate to add that the Linux kernel does this in an
extremely innovative and intelligent way. The more room you give your kernel
to cache, the more responsive it is going to be.

- --
Jonathan Gardner <jgardner(at)jonathangardner(dot)net>
(was jgardn(at)alumni(dot)washington(dot)edu)
Live Free, Use Linux!
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.1 (GNU/Linux)

iD8DBQE/AF8EWgwF3QvpWNwRArmVAJwK5C2ExmS8Rayrne33UJ0KZZM4UgCgq7b5
3J1LGtofgtnKq/bPtF75lNI=
=4Not
-----END PGP SIGNATURE-----