Thread: Increasing the number of semaphores on FreeBSD 4.1 (clarification)

Increasing the number of semaphores on FreeBSD 4.1 (clarification)

From
Philip Hallstrom
Date:
Hi -
    I recently tried to start postmaster (7.0.2) with -B 128 -N 64 and
got the "semget failed" error.  Looking in the faq[1] it says I need to
increase the amount allowed in the kernel.  It tells me what I need to do,
but my question is what values should I set them to?  Is there any way to
figure it out based on load, etc?  Also, are there detrimental effects to
setting them too high?

From the faq:

---------------------------------------------------------------------
3)  How to increasing the number of semaphores.

You may need to increase the number of sysv semaphores. By default,
PostgreSQL allocates 32 semaphores, one for each backend connection.
This is just over half the default system total of 60.

The defaults are in /sys/sys/sem.h:

/* Configuration parameters */
#ifndef SEMMNI
#define SEMMNI  10              /* # of semaphore identifiers */
#endif
#ifndef SEMMNS
#define SEMMNS  60              /* # of semaphores in system */
#endif
#ifndef SEMUME
#define SEMUME  10              /* max # of undo entries per process */
#endif
#ifndef SEMMNU
#define SEMMNU  30              /* # of undo structures in system */
#endif

Set the values you want in your kernel config file, e.g.:

options "SEMMNI=40"
options "SEMMNS=240"
options "SEMUME=40"
options "SEMMNU=120"
---------------------------------------------------------------------

Any insight appreciated.  Thanks!

[1]http://postgresql.readysetnet.com/docs/faq-bsdi


Re: Increasing the number of semaphores on FreeBSD 4.1 (clarification)

From
Alfred Perlstein
Date:
* Philip Hallstrom <philip@adhesivemedia.com> [001109 19:12] wrote:
> Hi -
>     I recently tried to start postmaster (7.0.2) with -B 128 -N 64 and
> got the "semget failed" error.  Looking in the faq[1] it says I need to
> increase the amount allowed in the kernel.  It tells me what I need to do,
> but my question is what values should I set them to?  Is there any way to
> figure it out based on load, etc?  Also, are there detrimental effects to
> setting them too high?

What OS are you using?

> [1]http://postgresql.readysetnet.com/docs/faq-bsdi

If it's FreeBSD we've documented the tunables here:
http://www.freebsd.org/cgi/cvsweb.cgi/src/sys/i386/conf/NOTES?rev=1.857

The docs will probably also help if you're using BSD/os.

Also you don't want to "go nuts" with raising these values, they
can cause the kernel to allocate too much memory for these structures
and cause problems booting or running your system.

--
-Alfred Perlstein - [bright@wintelcom.net|alfred@freebsd.org]
"I have the heart of a child; I keep it in a jar on my desk."

Re: Increasing the number of semaphores on FreeBSD 4.1 (clarification)

From
Philip Hallstrom
Date:
> * Philip Hallstrom <philip@adhesivemedia.com> [001109 19:12] wrote:
> > Hi -
> >     I recently tried to start postmaster (7.0.2) with -B 128 -N 64 and
> > got the "semget failed" error.  Looking in the faq[1] it says I need to
> > increase the amount allowed in the kernel.  It tells me what I need to do,
> > but my question is what values should I set them to?  Is there any way to
> > figure it out based on load, etc?  Also, are there detrimental effects to
> > setting them too high?
>
> What OS are you using?

FreeBSD 4.1

> > [1]http://postgresql.readysetnet.com/docs/faq-bsdi
>
> If it's FreeBSD we've documented the tunables here:
> http://www.freebsd.org/cgi/cvsweb.cgi/src/sys/i386/conf/NOTES?rev=1.857
>
> The docs will probably also help if you're using BSD/os.
>
> Also you don't want to "go nuts" with raising these values, they
> can cause the kernel to allocate too much memory for these structures
> and cause problems booting or running your system.

Yeah, that's what I've seen... I guess I was wondering if there were any
guidelines to raising them..  I mean should I up the defaults by 10?  Or
up them by a percentage (to keep the relationship), etc...

??


Re: Increasing the number of semaphores on FreeBSD 4.1 (clarification)

From
Alfred Perlstein
Date:
* Philip Hallstrom <philip@adhesivemedia.com> [001109 20:37] wrote:
>
> > * Philip Hallstrom <philip@adhesivemedia.com> [001109 19:12] wrote:
> > > Hi -
> > >     I recently tried to start postmaster (7.0.2) with -B 128 -N 64 and
> > > got the "semget failed" error.  Looking in the faq[1] it says I need to
> > > increase the amount allowed in the kernel.  It tells me what I need to do,
> > > but my question is what values should I set them to?  Is there any way to
> > > figure it out based on load, etc?  Also, are there detrimental effects to
> > > setting them too high?
> >
> > What OS are you using?
>
> FreeBSD 4.1
>
> > > [1]http://postgresql.readysetnet.com/docs/faq-bsdi
> >
> > If it's FreeBSD we've documented the tunables here:
> > http://www.freebsd.org/cgi/cvsweb.cgi/src/sys/i386/conf/NOTES?rev=1.857
> >
> > The docs will probably also help if you're using BSD/os.
> >
> > Also you don't want to "go nuts" with raising these values, they
> > can cause the kernel to allocate too much memory for these structures
> > and cause problems booting or running your system.
>
> Yeah, that's what I've seen... I guess I was wondering if there were any
> guidelines to raising them..  I mean should I up the defaults by 10?  Or
> up them by a percentage (to keep the relationship), etc...

here's what I use:

options         SHMMAXPGS=512000
options         SHMSEG=128
options         SEMMNI=40       #       /* # of semaphore identifiers */
options         SEMMNS=240      #       /* # of semaphores in system */
options         SEMUME=40       #       /* max # of undo entries per process */
options         SEMMNU=120      #       /* # of undo structures in system */

I have a gig of RAM though.

--
-Alfred Perlstein - [bright@wintelcom.net|alfred@freebsd.org]
"I have the heart of a child; I keep it in a jar on my desk."

Re: Increasing the number of semaphores on FreeBSD 4.1 (clarification)

From
Igor Roboul
Date:
On Thu, Nov 09, 2000 at 08:55:32PM -0800, Alfred Perlstein wrote:
> options         SHMMAXPGS=512000
> options         SHMSEG=128
> options         SEMMNI=40       #       /* # of semaphore identifiers */
> options         SEMMNS=240      #       /* # of semaphores in system */
> options         SEMUME=40       #       /* max # of undo entries per process */
> options         SEMMNU=120      #       /* # of undo structures in system */
These ooptions are not needed :-) There are sysctl settable options:
%sysctl -a | grep shm
kern.ipc.shmmax: 4194304
kern.ipc.shmmin: 1
kern.ipc.shmmni: 96
kern.ipc.shmseg: 64
kern.ipc.shmall: 1024
kern.ipc.shm_use_phys: 0


--
Igor Roboul, Unix System Administrator & Programmer @ sanatorium "Raduga",
Sochi, Russia
http://www.brainbench.com/transcript.jsp?pid=304744

Re: Increasing the number of semaphores on FreeBSD 4.1 (clarification)

From
Peter Eisentraut
Date:
Philip Hallstrom writes:

>     I recently tried to start postmaster (7.0.2) with -B 128 -N 64 and
> got the "semget failed" error.  Looking in the faq[1] it says I need to
> increase the amount allowed in the kernel.  It tells me what I need to do,
> but my question is what values should I set them to?  Is there any way to
> figure it out based on load, etc?  Also, are there detrimental effects to
> setting them too high?

This may help:

http://www.postgresql.org/devel-corner/docs/admin/kernel-resources.htm

--
Peter Eisentraut      peter_e@gmx.net       http://yi.org/peter-e/