Обсуждение: SHMMAX and SHMALL question

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

SHMMAX and SHMALL question

От
DM
Дата:
Firstof all sorry for posting linux kernel question in pgsql-general, but i am trying to figure out what value to set for postgresql db server.

RAM = 16GB, what value should i set for shmall?

If i set shmall to 4294967296 (4GB), current PAGE_SIZE is 4096 should i need to set my shmmax = 4294967296*4096 = 17592186044416?


cat /proc/sys/kernel/shmall
4294967296

getconf PAGE_SIZE
4096

Current Shmmax -
==> cat /proc/sys/kernel/shmmax
68719476736

should i need to increase my shmmax to
17592186044416?

also what value should i need to set shmall?

what happens if i set shmmax to lower  than the expected size?


Thanks
Deepak

Re: SHMMAX and SHMALL question

От
Scott Marlowe
Дата:
On Fri, Jan 21, 2011 at 6:34 PM, DM <dm.aeqa@gmail.com> wrote:
> Firstof all sorry for posting linux kernel question in pgsql-general, but i
> am trying to figure out what value to set for postgresql db server.
>
> RAM = 16GB, what value should i set for shmall?
>
> If i set shmall to 4294967296 (4GB),

shmall is measured in 4096 byte pages.  So, you wouldn't set it to
~2^32, but 2^32/2^12 so you'd set it to 2^20 or 1M pages for 4G of
space.

> current PAGE_SIZE is 4096 should i need
> to set my shmmax = 4294967296*4096 = 17592186044416?

shmmax is set in bytes, so no translaction needed, just set it to 2^32

(reference:
http://publib.boulder.ibm.com/infocenter/db2luw/v9/index.jsp?topic=/com.ibm.db2.udb.uprun.doc/doc/t0008238.htm)

Re: SHMMAX and SHMALL question

От
Greg Smith
Дата:
DM wrote:
> RAM = 16GB, what value should i set for shmall?

Given that PostgreSQL rarely sees increasing improvement as
shared_buffers goes over 50% of RAM, I just use that figure for the
shmall and then compute shmmax based on the page size to match it.  I
use the attached script to do all the hard work, haven't found a Linux
system yet it didn't do the right thing on.  It sounds like you might
have the math on the relation between the two backwards, look at the
output and code of this once and that should sort things out for you.

--
Greg Smith   2ndQuadrant US    greg@2ndQuadrant.com   Baltimore, MD
PostgreSQL Training, Services, and 24x7 Support  www.2ndQuadrant.us
"PostgreSQL 9.0 High Performance": http://www.2ndQuadrant.com/books

#!/bin/bash

# Output lines suitable for sysctl configuration based
# on total amount of RAM on the system.  The output
# will allow up to 50% of physical memory to be allocated
# into shared memory.

# On Linux, you can use it as follows (as root):
#
# ./shmsetup >> /etc/sysctl.conf
# sysctl -p

# Early FreeBSD versions do not support the sysconf interface
# used here.  The exact version where this works hasn't
# been confirmed yet.

page_size=`getconf PAGE_SIZE`
phys_pages=`getconf _PHYS_PAGES`

if [ -z "$page_size" ]; then
  echo Error:  cannot determine page size
  exit 1
fi

if [ -z "$phys_pages" ]; then
  echo Error:  cannot determine number of memory pages
  exit 2
fi

shmall=`expr $phys_pages / 2`
shmmax=`expr $shmall \* $page_size`

echo \# Maximum shared segment size in bytes
echo kernel.shmmax = $shmmax
echo \# Maximum number of shared memory segments in pages
echo kernel.shmall = $shmall

Re: SHMMAX and SHMALL question

От
D M
Дата:
Thank you so much for the script.

~deepak

On Jan 22, 2011, at 10:18 AM, Greg Smith <greg@2ndquadrant.com> wrote:

> DM wrote:
>> RAM = 16GB, what value should i set for shmall?
>
> Given that PostgreSQL rarely sees increasing improvement as shared_buffers goes over 50% of RAM, I just use that
figurefor the shmall and then compute shmmax based on the page size to match it.  I use the attached script to do all
thehard work, haven't found a Linux system yet it didn't do the right thing on.  It sounds like you might have the math
onthe relation between the two backwards, look at the output and code of this once and that should sort things out for
you.
>
> --
> Greg Smith   2ndQuadrant US    greg@2ndQuadrant.com   Baltimore, MD
> PostgreSQL Training, Services, and 24x7 Support  www.2ndQuadrant.us
> "PostgreSQL 9.0 High Performance": http://www.2ndQuadrant.com/books
>
> #!/bin/bash
>
> # Output lines suitable for sysctl configuration based
> # on total amount of RAM on the system.  The output
> # will allow up to 50% of physical memory to be allocated
> # into shared memory.
>
> # On Linux, you can use it as follows (as root):
> #
> # ./shmsetup >> /etc/sysctl.conf
> # sysctl -p
>
> # Early FreeBSD versions do not support the sysconf interface
> # used here.  The exact version where this works hasn't
> # been confirmed yet.
>
> page_size=`getconf PAGE_SIZE`
> phys_pages=`getconf _PHYS_PAGES`
>
> if [ -z "$page_size" ]; then
>  echo Error:  cannot determine page size
>  exit 1
> fi
>
> if [ -z "$phys_pages" ]; then
>  echo Error:  cannot determine number of memory pages
>  exit 2
> fi
>
> shmall=`expr $phys_pages / 2`
> shmmax=`expr $shmall \* $page_size`
>
> echo \# Maximum shared segment size in bytes
> echo kernel.shmmax = $shmmax
> echo \# Maximum number of shared memory segments in pages
> echo kernel.shmall = $shmall