pg.ddx.io  pgsql-admin@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Brendan Duddridge <brendan@clickspace.com>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: Maximilian Tyrtania <mty@fischerappelt.de>
Cc: pgsql-admin@postgresql.org <pgsql-admin@postgresql.org>
Subject: Re: shared memory settings on MAC OS X
Date: Sun, 11 Nov 2007 01:46:21 -0700
Message-ID: <8B947BD2-11D8-42CF-A14E-DCB895C7551E@clickspace.com> (raw)
In-Reply-To: <4731.1193665210@sss.pgh.pa.us>
References: <C34B62D9.2B38E%mty@fischerappelt.de>
	<4731.1193665210@sss.pgh.pa.us>

Either way, when you do manage to change your shared memory settings,  
you still won't be able to use more than about 4 GB of shared buffer  
space in Postgres, or any other program for that matter. We thought  
Leopard would help with this, but it hasn't. We have a 32 GB dual 3  
Ghz Intel Xeon Xserve, but we can't set our shared buffers as high as  
we'd like. We also have a similarly spec'd Linux machine and it has no  
problem allowing us to specify lots of shared buffers. For some  
reason, OS X gives an error when you try to attach to anything more  
than 4 GB.

Here's a program we wrote to demonstrate the problem, which we have  
submitted to Apple as a bug (Radar #5547628):

/*** create_shared_memory.c ***/
/* Takes as input from standard in a size in bytes for a shared memory  
segment
that this program will attempt to create and attach to. If any errors  
occur
trying to create or attach to the shared memory, they are printed to  
standard
out. This program will then attempt to detach from and delete the  
shared memory
it allocated and/or attached to as appropriate.

On Mac OS X 10.5 Server (9A557) on an Intel Quad core Xserve,  
compiling this
program with gcc version i686-apple-darwin9-gcc-4.0.1 as follows
#gcc -arch x86_64 create_shared_memory.c
you will see the maximum shared memory segment that can be attached to  
is
4292870144. I do not know if this shared memory limit applies to the  
final
version of Leopard Server or on other hardware.

Note: You will need greater than 4GB of memory on your machine and  
large enough
values set for kern.sysv.shmall and kern.sysv.shmmax to verify this  
shared
memory limit.

Known limitations: This program does not provide any output if the  
allocated
shared memory cannot be deallocated or if the attached shared memory  
cannot be
detached.

Written by: Brian Wipf
ClickSpace Interactive Inc.
Date: October 18, 2007
*/

#include <stdio.h>
#include <sys/types.h>
#include <sys/ipc.h>
#include <sys/shm.h>
#include <sys/errno.h>

typedef struct {
    int iPID;
} shared_t;

main()
{
    int key = 912367102; /* Some random key for the shared memory  
segment. */
    size_t size;
    int shmflg=IPC_CREAT | 0600;
    int shmid;
    shared_t  *shared_mem;

/* If you want to specify your own key, uncomment the next two lines  
of code. */
/*
    printf("Enter an integer key for shared memory segment: ");
    scanf("%d", &key);
*/
    printf("Enter size for shared memory segment (in bytes): ");
    scanf("%ld", &size);

    /* Create the shared memory segment */
    printf("\nAttempting to create the shared memory segment...\n");
    shmid=shmget(key, size, shmflg);

    if (errno != 0) {
       printf("There was an error trying to allocate the requested  
amount of shared memory\n");
       printf("errno: %d\n", errno);
    } else {
       printf("Shared memory created successfully\n");

       /* Attach to the shared memory segment */
       printf("\nAttempting to attach to the shared memory segment... 
\n");
       shared_mem = (shared_t *) shmat ( shmid, 0, 0);

       if (errno != 0) {
          printf("Error trying to attach to the shared memory segment. 
\n");
          printf("errno: %d\n\n", errno);
       } else {
          printf("Shared memory attached to successfully\n");

          /* Detach from shared memory segment */
          printf("\nDetaching from the shared memory segment\n\n");
          shmdt(shared_mem);
       }

       /* Delete the shared memory segment */
       printf("Deleting the shared memory segment\n");
       shmctl(shmid, IPC_RMID, NULL);
    }

    return 0;
}




____________________________________________________________________
Brendan Duddridge | CTO | 403-277-5591 x24 |  brendan@clickspace.com

ClickSpace Interactive Inc.
Suite L100, 239 - 10th Ave. SE
Calgary, AB  T2G 0V9

http://www.clickspace.com

On Oct 29, 2007, at 7:40 AM, Tom Lane wrote:

> Maximilian Tyrtania <mty@fischerappelt.de> writes:
>> Tom, I suspect you have Mac OS X Server installed, right? That's  
>> probably
>> why your /etc/sysctl.conf file mentions that /etc/sysctl- 
>> macosxserver.conf
>> file, while mine doesn't.
>
> Uh, no, I'm looking at my laptop.  Curious that yours has no reference
> to the other file.
>
>> And frankly, to me it looks as if it means "if there is a /etc/ 
>> sysctl.conf
>> file, then read it and accept its settings. Then overwrite the sysctl
>> settings with the default values, no matter what."
>
> You're forgetting the point I made that the first complete set of  
> shmem
> settings wins.  If we could change the settings on the fly after that,
> all this would be a whole lot easier, but the OSX kernel locks them  
> down
> somehow.
>
> BTW, I dunno if you read awk at all, but that awk command effectively
> says "print lines that contain = and do not contain #".  You didn't  
> try
> appending comments to the setting lines in your file did you?
>
> 			regards, tom lane
>
> ---------------------------(end of  
> broadcast)---------------------------
> TIP 2: Don't 'kill -9' the postmaster
>

Attachments:

  smime.p7s (application/pkcs7-signature, 2.4K) download

view thread (9+ messages)

Message-ID: <8B947BD2-11D8-42CF-A14E-DCB895C7551E@clickspace.com>
Permalink:  ../8B947BD2-11D8-42CF-A14E-DCB895C7551E@clickspace.com/
Also on:    postgresql.org/message-id/8B947BD2-11D8-42CF-A14E-DCB895C7551E@clickspace.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-admin@postgresql.org
  Cc: brendan@clickspace.com, tgl@sss.pgh.pa.us, mty@fischerappelt.de
  Subject: Re: shared memory settings on MAC OS X
  In-Reply-To: <8B947BD2-11D8-42CF-A14E-DCB895C7551E@clickspace.com>
  References: <C34B62D9.2B38E%mty@fischerappelt.de> <4731.1193665210@sss.pgh.pa.us> <8B947BD2-11D8-42CF-A14E-DCB895C7551E@clickspace.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox