Thread: PostgreSQL BSDI BSD/OS port

PostgreSQL BSDI BSD/OS port

From
"David J. MacKenzie"
Date:
Some corrections for the BSD/OS port.  BSD/OS doesn't define
LC_MESSAGES, so that needs to be ifdef'd, and the kernel tuning
parameters are incomplete and suboptimal.

Index: src/backend/utils/adt/pg_locale.c
===================================================================
RCS file: /export/src/CVS/usr.local/bin/postgresql-7.0/src/backend/utils/adt/pg_locale.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- src/backend/utils/adt/pg_locale.c    2000/06/30 21:15:43    1.1
+++ src/backend/utils/adt/pg_locale.c    2000/06/30 22:51:00    1.2
@@ -40,7 +40,9 @@
     lc->lc_time = setlocale(LC_TIME, NULL);
     lc->lc_collate = setlocale(LC_COLLATE, NULL);
     lc->lc_monetary = setlocale(LC_MONETARY, NULL);
+#ifdef LC_MESSAGES
     lc->lc_messages = setlocale(LC_MESSAGES, NULL);
+#endif /* LC_MESSAGES */

     return lc;
 }
@@ -62,7 +64,11 @@
          lc->lc_time,
          lc->lc_collate,
          lc->lc_monetary,
+#ifdef LC_MESSAGES
          lc->lc_messages
+#else /* LC_MESSAGES */
+         "unimplemented"
+#endif /* LC_MESSAGES */
     );

     return lc;
@@ -92,8 +98,10 @@
     if (!setlocale(LC_MONETARY, lc->lc_monetary))
         elog(NOTICE, "pg_setlocale(): 'LC_MONETARY=%s' cannot be honored.", lc->lc_monetary);

+#ifdef LC_MESSAGES
     if (!setlocale(LC_MESSAGES, lc->lc_messages))
         elog(NOTICE, "pg_setlocale(): 'LC_MESSAGE=%s' cannot be honored.", lc->lc_messages);
+#endif /* LC_MESSAGES */

     return lc;
 }

Index: doc/FAQ_BSDI
===================================================================
diff -u -r1.1 -r1.2
--- doc/FAQ_BSDI    2000/06/30 21:15:35    1.1
+++ doc/FAQ_BSDI    2000/07/07 14:23:18    1.2
@@ -8,12 +8,49 @@

 ---------------------------------------------------------------------------

+You may need to increase the number of sysv semaphores.
+PostgreSQL 7 allowing the default number of backend connections
+allocates 32 semaphores, which 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"
+
+---------------------------------------------------------------------------
+
 Increase SHMMAXPGS by 1024 for every additional 4MB of shared
 memory:

 /sys/sys/shm.h:69:#define       SHMMAXPGS       1024    /* max hardware pages...

 The default setting of 1024 is for a maximum of 4MB of shared memory.
+PostgresSQL 7 allowing the default number of backend connections
+allocates about 1.2MB of shared memory.
+
+Enclose the above line with "#ifndef SHMMAXPGS" and "#endif", and in
+your kernel config file set the desired value, e.g.:
+
+options "SHMMAXPGS=8192"

 For those running 4.1 or later, just recompile the kernel and reboot.
 For those running earlier releases, there are more steps outlined below.
@@ -24,11 +61,17 @@
 This is computed dynamically at bootup.

     $ bpatch -r sysptsize
-    0x9 = 9
+    0x16 = 22

-Next, change SYSPTSIZE to a hard-coded value.  Use the bpatch value,
-plus add 1 for every additional 4MB of shared memory you desire.
+Set SYSPTSIZE in your kernel config file, e.g.:

+options "SYSPTSIZE=29"
+
+Use the bpatch value, plus add 1 for every additional 4MB of shared
+memory you desire.  For reference, the default is set here:
+
 /sys/i386/i386/i386_param.c:28:#define  SYSPTSIZE 0        /* dynamically...

 sysptsize can not be changed by sysctl on the fly.
+
+---------------------------------------------------------------------------

Re: PostgreSQL BSDI BSD/OS port

From
Bruce Momjian
Date:
I have already fixed the LC_MESSAGES issue for 7.1.

I have made a new BSDI item #3 for your semaphore changes.  I did not
make the shared memory changes you suggested because it requires changes
to the kernel include files and the config files.  I prefer suggestting
the change only in one place.  If it were not for the requirement of
#ifndef, I would prefer the config file change.

New BSDI FAQ version attached:

> Some corrections for the BSD/OS port.  BSD/OS doesn't define
> LC_MESSAGES, so that needs to be ifdef'd, and the kernel tuning
> parameters are incomplete and suboptimal.
>
> Index: src/backend/utils/adt/pg_locale.c
> ===================================================================
> RCS file: /export/src/CVS/usr.local/bin/postgresql-7.0/src/backend/utils/adt/pg_locale.c,v
> retrieving revision 1.1
> retrieving revision 1.2
> diff -u -r1.1 -r1.2
> --- src/backend/utils/adt/pg_locale.c    2000/06/30 21:15:43    1.1
> +++ src/backend/utils/adt/pg_locale.c    2000/06/30 22:51:00    1.2
> @@ -40,7 +40,9 @@
>      lc->lc_time = setlocale(LC_TIME, NULL);
>      lc->lc_collate = setlocale(LC_COLLATE, NULL);
>      lc->lc_monetary = setlocale(LC_MONETARY, NULL);
> +#ifdef LC_MESSAGES
>      lc->lc_messages = setlocale(LC_MESSAGES, NULL);
> +#endif /* LC_MESSAGES */
>
>      return lc;
>  }
> @@ -62,7 +64,11 @@
>           lc->lc_time,
>           lc->lc_collate,
>           lc->lc_monetary,
> +#ifdef LC_MESSAGES
>           lc->lc_messages
> +#else /* LC_MESSAGES */
> +         "unimplemented"
> +#endif /* LC_MESSAGES */
>      );
>
>      return lc;
> @@ -92,8 +98,10 @@
>      if (!setlocale(LC_MONETARY, lc->lc_monetary))
>          elog(NOTICE, "pg_setlocale(): 'LC_MONETARY=%s' cannot be honored.", lc->lc_monetary);
>
> +#ifdef LC_MESSAGES
>      if (!setlocale(LC_MESSAGES, lc->lc_messages))
>          elog(NOTICE, "pg_setlocale(): 'LC_MESSAGE=%s' cannot be honored.", lc->lc_messages);
> +#endif /* LC_MESSAGES */
>
>      return lc;
>  }
>
> Index: doc/FAQ_BSDI
> ===================================================================
> diff -u -r1.1 -r1.2
> --- doc/FAQ_BSDI    2000/06/30 21:15:35    1.1
> +++ doc/FAQ_BSDI    2000/07/07 14:23:18    1.2
> @@ -8,12 +8,49 @@
>
>  ---------------------------------------------------------------------------
>
> +You may need to increase the number of sysv semaphores.
> +PostgreSQL 7 allowing the default number of backend connections
> +allocates 32 semaphores, which 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"
> +
> +---------------------------------------------------------------------------
> +
>  Increase SHMMAXPGS by 1024 for every additional 4MB of shared
>  memory:
>
>  /sys/sys/shm.h:69:#define       SHMMAXPGS       1024    /* max hardware pages...
>
>  The default setting of 1024 is for a maximum of 4MB of shared memory.
> +PostgresSQL 7 allowing the default number of backend connections
> +allocates about 1.2MB of shared memory.
> +
> +Enclose the above line with "#ifndef SHMMAXPGS" and "#endif", and in
> +your kernel config file set the desired value, e.g.:
> +
> +options "SHMMAXPGS=8192"
>
>  For those running 4.1 or later, just recompile the kernel and reboot.
>  For those running earlier releases, there are more steps outlined below.
> @@ -24,11 +61,17 @@
>  This is computed dynamically at bootup.
>
>      $ bpatch -r sysptsize
> -    0x9 = 9
> +    0x16 = 22
>
> -Next, change SYSPTSIZE to a hard-coded value.  Use the bpatch value,
> -plus add 1 for every additional 4MB of shared memory you desire.
> +Set SYSPTSIZE in your kernel config file, e.g.:
>
> +options "SYSPTSIZE=29"
> +
> +Use the bpatch value, plus add 1 for every additional 4MB of shared
> +memory you desire.  For reference, the default is set here:
> +
>  /sys/i386/i386/i386_param.c:28:#define  SYSPTSIZE 0        /* dynamically...
>
>  sysptsize can not be changed by sysctl on the fly.
> +
> +---------------------------------------------------------------------------
>


--
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 853-3000
  +  If your life is a hard drive,     |  830 Blythe Avenue
  +  Christ can be your backup.        |  Drexel Hill, Pennsylvania 19026
This outlines modifications to BSD/OS for running PostgreSQL:

1)  How to increase resource limits
2)  How to increase the number of shared memory buffers
3)  How to increasing the number of semaphores

Bruce Momjian (pgman@candle.pha.pa.us)  2000-07-7

---------------------------------------------------------------------------

1)  To increase the amount of malloc'ed memory and files opened by
PostgreSQL, add this:

          :datasize-cur=600M:\
          :openfiles-cur=256:

to your /etc/login.conf file.

---------------------------------------------------------------------------

2a)  By default, only 4MB of shared memory is supported by BSDI. Keep in
mind that shared memory is not pageable.  It is locked in RAM.

To increase the number of buffers supported by the postmaseter, increase
SHMMAXPGS by 1024 for every additional 4MB of shared memory:

/sys/sys/shm.h:69:#define       SHMMAXPGS       1024    /* max hardware pages...

The default setting of 1024 is for a maximum of 4MB of shared memory.

For those running 4.1 or later, just recompile the kernel and reboot.
For those running earlier releases, see step 2b.

---------------------------------------------------------------------------

2b)  For 4.01 and earlier, use bpatch to find the sysptsize value for
the current kernel.  This is computed dynamically at bootup.

    $ bpatch -r sysptsize
    0x9 = 9

Next, change SYSPTSIZE to a hard-coded value.  Use the bpatch value,
plus add 1 for every additional 4MB of shared memory you desire.

/sys/i386/i386/i386_param.c:28:#define  SYSPTSIZE 0        /* dynamically...

sysptsize can not be changed by sysctl on the fly.

---------------------------------------------------------------------------

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"


Re: PostgreSQL BSDI BSD/OS port

From
"David J. MacKenzie"
Date:
> I have made a new BSDI item #3 for your semaphore changes.  I did not
> make the shared memory changes you suggested because it requires changes
> to the kernel include files and the config files.  I prefer suggestting
> the change only in one place.  If it were not for the requirement of
> #ifndef, I would prefer the config file change.

Perhaps you're in a small organization?  We're a large ISP and
build several kernels with different configurations from the same BSDI
source tree, for use on machines with different purposes and hardware.
So setting the values in the include files is not an option for us.

I've sent mail to BSDI suggesting that they add the #ifdef, so perhaps
it will be there in BSD/OS 4.2.

Re: PostgreSQL BSDI BSD/OS port

From
Bruce Momjian
Date:
>
> > I have made a new BSDI item #3 for your semaphore changes.  I did not
> > make the shared memory changes you suggested because it requires changes
> > to the kernel include files and the config files.  I prefer suggestting
> > the change only in one place.  If it were not for the requirement of
> > #ifndef, I would prefer the config file change.
>
> Perhaps you're in a small organization?  We're a large ISP and
> build several kernels with different configurations from the same BSDI
> source tree, for use on machines with different purposes and hardware.
> So setting the values in the include files is not an option for us.

I don't suggest complex solutions in FAQ's.  If people want to do
complex things on their end, they are welcome to do it.

>
> I've sent mail to BSDI suggesting that they add the #ifdef, so perhaps
> it will be there in BSD/OS 4.2.
>

I thought 4.1 would automatically size SYSPTSIZE based on the shared memory
configured.  At least that is what BSDI support said.  They said the
SYSPTSIZE change would not be neeeed in 4.1.  If you don't make the
SYSPTSIZE too, does the kernel still boot with larger shared memory
segments?




--
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 853-3000
  +  If your life is a hard drive,     |  830 Blythe Avenue
  +  Christ can be your backup.        |  Drexel Hill, Pennsylvania 19026

Re: PostgreSQL BSDI BSD/OS port

From
"David J. MacKenzie"
Date:
> I don't suggest complex solutions in FAQ's.  If people want to do
> complex things on their end, they are welcome to do it.

Oh, it's not *that* complex!  And it works for everyone, not just
people with simple installations.  It's really The Right Way to do it,
IMHO.

> > I've sent mail to BSDI suggesting that they add the #ifdef, so perhaps
> > it will be there in BSD/OS 4.2.

Note that I am referring here to a #ifndef around SHMMAXPGS.
SYSPTSIZE already has an #ifndef as shipped, so my suggestion just
makes them more symmetrical.

> I thought 4.1 would automatically size SYSPTSIZE based on the shared memory
> configured.  At least that is what BSDI support said.  They said the
> SYSPTSIZE change would not be neeeed in 4.1.  If you don't make the
> SYSPTSIZE too, does the kernel still boot with larger shared memory
> segments?

We've only got 4.1 up on a couple of test machines--we're still doing
everything important on 4.0.1 and at this point we're going to skip
4.1 and our next upgrade will be to 4.2 since that's in beta already.

In other words, I don't know :-(

Re: PostgreSQL BSDI BSD/OS port

From
Bruce Momjian
Date:
> > > I've sent mail to BSDI suggesting that they add the #ifdef, so perhaps
> > > it will be there in BSD/OS 4.2.
>
> Note that I am referring here to a #ifndef around SHMMAXPGS.
> SYSPTSIZE already has an #ifndef as shipped, so my suggestion just
> makes them more symmetrical.

I expect 4.1 will not require any change to SYSPTSIZE.  It will
auto-size based on the shared memory required.

>
> > I thought 4.1 would automatically size SYSPTSIZE based on the shared memory
> > configured.  At least that is what BSDI support said.  They said the
> > SYSPTSIZE change would not be neeeed in 4.1.  If you don't make the
> > SYSPTSIZE too, does the kernel still boot with larger shared memory
> > segments?
>
> We've only got 4.1 up on a couple of test machines--we're still doing
> everything important on 4.0.1 and at this point we're going to skip
> 4.1 and our next upgrade will be to 4.2 since that's in beta already.

Same here.

--
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 853-3000
  +  If your life is a hard drive,     |  830 Blythe Avenue
  +  Christ can be your backup.        |  Drexel Hill, Pennsylvania 19026