Re: Posix Shared Mem patch

From: Josh Berkus <josh(at)agliodbs(dot)com>
To: Robert Haas <robertmhaas(at)gmail(dot)com>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Magnus Hagander <magnus(at)hagander(dot)net>, Andres Freund <andres(at)2ndquadrant(dot)com>, pgsql-hackers(at)postgresql(dot)org, Thom Brown <thom(at)linux(dot)com>
Subject: Re: Posix Shared Mem patch
Date: 2012-06-29 17:08:09
Message-ID: 4FEDE0F9.2020902@agliodbs.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers


> According to the Google, there is absolutely no way of gettIng MacOS X
> not to overcommit like crazy.

Well, this is one of a long list of broken things about OSX. If you
want to see *real* breakage, do some IO performance testing of HFS+

FWIW, I have this issue with Mac desktop applications on my MacBook,
which will happily memory leak until I run out of swap space.

> You can read the amount of system
> memory by using sysctl() to fetch hw.memsize, but it's not really
> clear how much that helps. We could refuse to start up if the shared
> memory allocation is >= hw.memsize, but even an amount slightly less
> than that seems like enough to send the machine into a tailspin, so
> I'm not sure that really gets us anywhere.

I still think it would help. User errors in allocating shmmem are more
likely to be order-of-magnitude errors ("I meant 500MB, not 500GB!")
than be matters of 20% of RAM over.

> One idea I had was to LOG the size of the shared memory allocation
> just before allocating it. That way, if your system goes into the
> tank, there will at least be something in the log. But that would be
> useless chatter for most users.

Yes, but it would provide mailing list, IRC and StackExchange quick answers.

"I started up PostgreSQL and my MacBook crashed."

"Find the file postgres.log. What's the last 10 lines?"

So neither of those things *fixes* the problem ... ultimately, it's
Apple's problem and we can't fix it ... but both of them make it
somewhat better.

The other thing which will avoid the problem for most Mac users is if we
simply allocate 10% of RAM at initdb as a default. If we do that, then
90% of users will never touch Shmem themselves, and not have the
opportunity to mess up.

--
Josh Berkus
PostgreSQL Experts Inc.
http://pgexperts.com

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Andres Freund 2012-06-29 17:11:51 Re: Update on the spinlock->pthread_mutex patch experimental: replace s_lock spinlock code with pthread_mutex on linux
Previous Message Nils Goroll 2012-06-29 17:07:11 Update on the spinlock->pthread_mutex patch experimental: replace s_lock spinlock code with pthread_mutex on linux