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. */