pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Sean Chittenden <seanc@joyent.com>
To: pgsql-hackers@postgresql.org
Cc: stadtkind2@gmx.de, Sam Gwydir <sam.gwydir@joyent.com>
Cc: Sean Chittenden <sean@chittenden.org>
Cc: pgsql-bugs@postgresql.org
Subject: Re: [PATCH] BUG #13416: Postgres >= 9.3 doesn't use optimized shared memory on Solaris anymore
Date: Tue, 3 Oct 2017 16:11:57 -0700
Message-ID: <f2ba267d-3a6d-4ffb-b842-9d6d1c0b3b1e@Spark> (raw)
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-bugs>

Hello.  We identified the same problem.  Sam Gwydir and Josh Clulow were able to put together the appropriate fix after.

The breakage in src/backend/port/sysv_shmem.c and src/include/storage/dsm_impl.h should be back ported to all supported versions (the regression was introduced between the 9.2 and 9.3 branches).

The only real question remaining is: do we want to change the default behavior, as detected by initdb(1), to use ISM on Illumos/Solaris derived systems?  Given the memory bloat experienced when using POSIX shared memory (potentially very significant for systems with larger shared_buffers), we think it's probably prudent to change the default from dynamic_shared_memory_type=posix to sysv.  Unfortunately I think it's not worth changing the default behavior of initdb(1) in the current supported branches, but it should be changed for 10.

Please let us know if there are any questions.  -sc


--
Sean Chittenden
seanc@joyent.com

-- 
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs

Attachments:

ism.patch (application/octet-stream, 3.3K) download diff --git a/src/backend/port/sysv_shmem.c b/src/backend/port/sysv_shmem.c index 850eafddc3..0a8e1bb342 100644 --- a/src/backend/port/sysv_shmem.c +++ b/src/backend/port/sysv_shmem.c @@ -55,15 +55,20 @@ * false, we might need to add compile and/or run-time tests here and do this * only if the running kernel supports it. * - * However, we must always disable this logic in the EXEC_BACKEND case, and + * There are two cases in which we disable this logic. On systems that support + * intimate shared memory (e.g. illumos and Solaris), we prefer the usage of + * System V shared memory in order to take advantage of the performance + * improvements that sharing page tables provides. + * + * In addition, we must always disable this logic in the EXEC_BACKEND case, and * fall back to the old method of allocating the entire segment using System V * shared memory, because there's no way to attach an anonymous mmap'd segment * to a process after exec(). Since EXEC_BACKEND is intended only for * developer use, this shouldn't be a big problem. Because of this, we do * not worry about supporting anonymous shmem in the EXEC_BACKEND cases below. */ -#ifndef EXEC_BACKEND -#define USE_ANONYMOUS_SHMEM +#if !defined(EXEC_BACKEND) && !defined(SHM_SHARE_MMU) +# define USE_ANONYMOUS_SHMEM #endif diff --git a/src/bin/initdb/initdb.c b/src/bin/initdb/initdb.c index 27d134e17d..329ed88c8b 100644 --- a/src/bin/initdb/initdb.c +++ b/src/bin/initdb/initdb.c @@ -1050,12 +1050,13 @@ set_null_conf(void) * attempt to reproduce what the postmaster will do when allocating a POSIX * segment in dsm_impl.c; if it doesn't work, we assume it won't work for * the postmaster either, and configure the cluster for System V shared - * memory instead. + * memory instead. However, on Solaris-derived systems, System V shared + * memory is preferred. */ static char * choose_dsm_implementation(void) { -#ifdef HAVE_SHM_OPEN +#if defined(HAVE_SHM_OPEN) && !defined(__sun) int ntries = 10; while (ntries > 0) diff --git a/src/include/storage/dsm_impl.h b/src/include/storage/dsm_impl.h index ec05e22a6b..af0d32fcb5 100644 --- a/src/include/storage/dsm_impl.h +++ b/src/include/storage/dsm_impl.h @@ -23,20 +23,22 @@ /* * Determine which dynamic shared memory implementations will be supported * on this platform, and which one will be the default. + * Note for systems which feature SHM_SHARE_MMU (e.g. illumos and Solaris) + * we prefer System V Shared Memory instead of POSIX Shared Memory. */ #ifdef WIN32 -#define USE_DSM_WINDOWS -#define DEFAULT_DYNAMIC_SHARED_MEMORY_TYPE DSM_IMPL_WINDOWS -#else -#ifdef HAVE_SHM_OPEN -#define USE_DSM_POSIX -#define DEFAULT_DYNAMIC_SHARED_MEMORY_TYPE DSM_IMPL_POSIX -#endif -#define USE_DSM_SYSV -#ifndef DEFAULT_DYNAMIC_SHARED_MEMORY_TYPE -#define DEFAULT_DYNAMIC_SHARED_MEMORY_TYPE DSM_IMPL_SYSV -#endif -#define USE_DSM_MMAP +# define USE_DSM_WINDOWS +# define DEFAULT_DYNAMIC_SHARED_MEMORY_TYPE DSM_IMPL_WINDOWS +# else +# ifdef HAVE_SHM_OPEN +# define USE_DSM_POSIX +# define DEFAULT_DYNAMIC_SHARED_MEMORY_TYPE DSM_IMPL_POSIX +# endif +# define USE_DSM_SYSV +# if !defined(DEFAULT_DYNAMIC_SHARED_MEMORY_TYPE) || defined(SHM_SHARE_MMU) +# define DEFAULT_DYNAMIC_SHARED_MEMORY_TYPE DSM_IMPL_SYSV +# endif +# define USE_DSM_MMAP #endif /* GUC. */

view thread (5+ messages)  latest in thread

Message-ID: <f2ba267d-3a6d-4ffb-b842-9d6d1c0b3b1e@Spark>
Permalink:  ../f2ba267d-3a6d-4ffb-b842-9d6d1c0b3b1e@Spark/
Also on:    postgresql.org/message-id/f2ba267d-3a6d-4ffb-b842-9d6d1c0b3b1e@Spark

 ·  · 

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-bugs@postgresql.org
  Cc: seanc@joyent.com, pgsql-hackers@postgresql.org, sam.gwydir@joyent.com, sean@chittenden.org
  Subject: Re: [PATCH] BUG #13416: Postgres >= 9.3 doesn't use optimized shared memory on Solaris anymore
  In-Reply-To: <f2ba267d-3a6d-4ffb-b842-9d6d1c0b3b1e@Spark>
  References: <f2ba267d-3a6d-4ffb-b842-9d6d1c0b3b1e@Spark>

* 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