On Mon, Oct 13, 2014 at 11:35:18AM -0400, Bruce Momjian wrote: > On Mon, Oct 13, 2014 at 05:21:32PM +0200, Andres Freund wrote: > > > If we have it, we should improve it, or remove it. We might want to use > > > this code for something else in the future, so it should be improved > > > where feasible. > > > > Meh. We don't put in effort into code that doesn't matter just because > > it might get used elsewhere some day. By that argument we'd need to > > performance optimize a lot of code. And actually, using that code > > somewhere else is more of a counter indication than a pro > > argument. MAP_NOSYNC isn't a general purpose flag. > > The key is that this is platform-specific behavior, so if we should use > a flag to use it right, we should. You are right that optimizing > rarely used code with generic calls isn't a good use of time.
I have adjusted Sean's mmap() options patch to match our C layout and plan to apply this to head, as it is from August. -- Bruce Momjian <br...@momjian.us> http://momjian.us EnterpriseDB http://enterprisedb.com + Everyone has their own god. +
diff --git a/src/backend/storage/ipc/dsm_impl.c b/src/backend/storage/ipc/dsm_impl.c new file mode 100644 index cf7938c..0859fbf *** a/src/backend/storage/ipc/dsm_impl.c --- b/src/backend/storage/ipc/dsm_impl.c *************** dsm_impl_posix(dsm_op op, dsm_handle han *** 368,374 **** /* Map it. */ address = mmap(NULL, request_size, PROT_READ | PROT_WRITE, ! MAP_SHARED | MAP_HASSEMAPHORE, fd, 0); if (address == MAP_FAILED) { int save_errno; --- 368,374 ---- /* Map it. */ address = mmap(NULL, request_size, PROT_READ | PROT_WRITE, ! MAP_SHARED | MAP_HASSEMAPHORE | MAP_NOSYNC, fd, 0); if (address == MAP_FAILED) { int save_errno; *************** dsm_impl_mmap(dsm_op op, dsm_handle hand *** 960,966 **** /* Map it. */ address = mmap(NULL, request_size, PROT_READ | PROT_WRITE, ! MAP_SHARED | MAP_HASSEMAPHORE, fd, 0); if (address == MAP_FAILED) { int save_errno; --- 960,966 ---- /* Map it. */ address = mmap(NULL, request_size, PROT_READ | PROT_WRITE, ! MAP_SHARED | MAP_HASSEMAPHORE | MAP_NOSYNC, fd, 0); if (address == MAP_FAILED) { int save_errno; diff --git a/src/include/portability/mem.h b/src/include/portability/mem.h new file mode 100644 index 7c77dbd..a4b01fe *** a/src/include/portability/mem.h --- b/src/include/portability/mem.h *************** *** 30,35 **** --- 30,43 ---- #define MAP_HASSEMAPHORE 0 #endif + /* + * BSD-derived systems use the MAP_NOSYNC flag to prevent dirty mmap(2) + * pages from being gratuitously flushed to disk. + */ + #ifndef MAP_NOSYNC + #define MAP_NOSYNC 0 + #endif + #define PG_MMAP_FLAGS (MAP_SHARED|MAP_ANONYMOUS|MAP_HASSEMAPHORE) /* Some really old systems don't define MAP_FAILED. */
-- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers