pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Michael Paquier <michael@paquier.xyz>
To: Julien Rouhaud <rjuju123@gmail.com>
Cc: Wilm Hoyer <W.Hoyer@dental-vision.de>
Cc: pgsql-hackers@lists.postgresql.org
Subject: Re: BUG #17448: In Windows 10, version 1703 and later, huge_pages doesn't work.
Date: Fri, 8 Jul 2022 07:38:49 +0900
Message-ID: <YsdgeTimQONuzEDQ@paquier.xyz> (raw)
In-Reply-To: <Ymd7C+QineDpi7Eb@jrouhaud>
References: <20220326082408.moh55zuecxjmewnm@jrouhaud>
	<CA+hUKGLwOSf-QwVtCcKx9xvugN2BSzEBBeD5DNyTXgcSRp5sTw@mail.gmail.com>
	<YkQMyhsP7xgLDDT/@paquier.xyz>
	<20220331045908.bm5edcacvymgwwv2@jrouhaud>
	<YkVbbZBiC4yxXPuc@paquier.xyz>
	<20220331080055.hjrrsrd4lxwlt7f5@jrouhaud>
	<20220331104659.ol6pqe7s3tpkymuk@jrouhaud>
	<20220331110309.ws25d6dl5yyzprye@jrouhaud>
	<a6859029835d4abdb6ba2970614905d1@dental-vision.de>
	<Ymd7C+QineDpi7Eb@jrouhaud>

On Tue, Apr 26, 2022 at 12:54:35PM +0800, Julien Rouhaud wrote:
> Their API is entirely useless, so I'm still on the opinion that we should
> unconditionally use the FILE_MAP_LARGE_PAGES flag if it's defined and call it a
> day.

Now that the minimal runtime version is Windows 10 in v16~ thanks to
495ed0e, we could be much more aggressive and do the attached, which
is roughly what Thomas has proposed upthread at the exception of
assuming that FILE_MAP_LARGE_PAGES always exists, because updates are
forced by MS in this environment.  We could make it conditional, of
course, with an extra #ifdef painting.
--
Michael

Attachments:

v2-0001-Fix-huge_pages-on-current-Windows.patch (text/x-diff, 1.7K) download From 9a1450ecbe291cfc92e97f49506db9f443c8cbe9 Mon Sep 17 00:00:00 2001 From: Michael Paquier <michael@paquier.xyz> Date: Thu, 7 Jul 2022 16:51:18 +0900 Subject: [PATCH v2] Fix huge_pages on current Windows. Since Windows 10 1703, it's necessary to pass a flag to MapViewOfFile() to enable large pages at map time. Reported-by: Okano Naoki Author: Thomas Munro Discussion: https://postgr.es/m/17448-0a96583a67edb1f7%40postgresql.org --- src/backend/port/win32_shmem.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/backend/port/win32_shmem.c b/src/backend/port/win32_shmem.c index 6cf69411db..2f51da5a6a 100644 --- a/src/backend/port/win32_shmem.c +++ b/src/backend/port/win32_shmem.c @@ -216,6 +216,7 @@ PGSharedMemoryCreate(Size size, SIZE_T largePageSize = 0; Size orig_size = size; DWORD flProtect = PAGE_READWRITE; + DWORD desiredAccess; ShmemProtectiveRegion = VirtualAlloc(NULL, PROTECTIVE_REGION_SIZE, MEM_RESERVE, PAGE_NOACCESS); @@ -353,12 +354,17 @@ retry: if (!CloseHandle(hmap)) elog(LOG, "could not close handle to shared memory: error code %lu", GetLastError()); + desiredAccess = FILE_MAP_WRITE | FILE_MAP_READ; + + /* Set large pages if wanted. */ + if ((flProtect & SEC_LARGE_PAGES) != 0) + desiredAccess |= FILE_MAP_LARGE_PAGES; /* * Get a pointer to the new shared memory segment. Map the whole segment * at once, and let the system decide on the initial address. */ - memAddress = MapViewOfFileEx(hmap2, FILE_MAP_WRITE | FILE_MAP_READ, 0, 0, 0, NULL); + memAddress = MapViewOfFileEx(hmap2, desiredAccess, 0, 0, 0, NULL); if (!memAddress) ereport(FATAL, (errmsg("could not create shared memory segment: error code %lu", GetLastError()), -- 2.36.1
signature.asc (application/pgp-signature, 832B) download

view thread (25+ messages)  latest in thread

Message-ID: <YsdgeTimQONuzEDQ@paquier.xyz>
Permalink:  ../YsdgeTimQONuzEDQ@paquier.xyz/
Also on:    postgresql.org/message-id/YsdgeTimQONuzEDQ@paquier.xyz

 ·  · 

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 using the --to and --cc options:
  reply via email

  To: pgsql-bugs@postgresql.org
  Cc: michael@paquier.xyz, rjuju123@gmail.com, W.Hoyer@dental-vision.de, pgsql-hackers@lists.postgresql.org
  Subject: Re: BUG #17448: In Windows 10, version 1703 and later, huge_pages doesn't work.
  In-Reply-To: <YsdgeTimQONuzEDQ@paquier.xyz>

* 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