Re: Memory reporting on CentOS Linux

From: Greg Smith <gsmith(at)gregsmith(dot)com>
To: Scott Carey <scott(at)richrelevance(dot)com>
Cc: Jeremy Carroll <jeremy(dot)carroll(at)networkedinsights(dot)com>, "pgsql-performance(at)postgresql(dot)org" <pgsql-performance(at)postgresql(dot)org>
Subject: Re: Memory reporting on CentOS Linux
Date: 2009-08-18 04:33:01
Message-ID: alpine.GSO.2.01.0908180005320.15114@westnet.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

On Fri, 14 Aug 2009, Scott Carey wrote:

> The memory used by postgres for shared memory is the largest of all SHR
> columns for postgres columns. Or, about 7.9GB. So, postgres is using
> about 7.9GB for shared memory, and very little for anything else.

It's a good idea to check this result against the actual shared memory
block allocated. If the server has been up long enough to go through all
of shared_buffers once, the results should be close. You can look at the
block under Linux using "ipcs -m"; the one you want should look something
like this:

------ Shared Memory Segments --------
key shmid owner perms bytes nattch status
0x0052e2c1 21757972 gsmith 600 548610048 10

That represents a bit over 512MB worth of allocated memory for the server.
Alternately, you can use "pmap -d" on a PostgreSQL process to find the
block, something like this works:

$ pmap -d 13961 | egrep "^Address|shmid"
Address Kbytes Mode Offset Device Mapping
96c41000 535752 rw-s- 0000000000000000 000:00009 [ shmid=0x14c0014 ]

I have given up on presuming the summary values top shows are good for
anything on Linux. I look at /proc/meminfo to see how much RAM is free,
and to figure out what's going on with the server processes I use:

ps -e -o pid,rss,vsz,size,cmd | grep postgres

And compute my own totals (one of these days I'm going to script that
process). Useful reading on this topic:

http://virtualthreads.blogspot.com/2006/02/understanding-memory-usage-on-linux.html
http://mail.nl.linux.org/linux-mm/2003-03/msg00077.html
http://forums.gentoo.org/viewtopic.php?t=175419

Most confusion about what's going on here can be resolved by spending some
quality time with pmap.

--
* Greg Smith gsmith(at)gregsmith(dot)com http://www.gregsmith.com Baltimore, MD

In response to

Browse pgsql-performance by date

  From Date Subject
Next Message Scott Marlowe 2009-08-18 07:08:46 Re: number of rows estimation for bit-AND operation
Previous Message Russell Smith 2009-08-18 04:25:57 Re: Getting time of a postgresql-request