Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1o9a9E-0005DO-TV for pgsql-hackers@arkaria.postgresql.org; Thu, 07 Jul 2022 22:39:01 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1o9a9D-0007Js-O6 for pgsql-hackers@arkaria.postgresql.org; Thu, 07 Jul 2022 22:38:59 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1o9a9D-0007H5-DD for pgsql-hackers@lists.postgresql.org; Thu, 07 Jul 2022 22:38:59 +0000 Received: from wout4-smtp.messagingengine.com ([64.147.123.20]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1o9a9A-0003Oc-Ni for pgsql-hackers@lists.postgresql.org; Thu, 07 Jul 2022 22:38:59 +0000 Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailout.west.internal (Postfix) with ESMTP id ABF263200978; Thu, 7 Jul 2022 18:38:54 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute3.internal (MEProxy); Thu, 07 Jul 2022 18:38:55 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paquier.xyz; h= cc:cc:content-type:date:date:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:sender:subject :subject:to:to; s=fm3; t=1657233534; x=1657319934; bh=pzEwDxpTkS IX6cxGUKDE8VohgBWptGlFqLxlQ68bMbA=; b=Go+ViOTPoIsSrBALpXVJvi+RRe P4dwWDPuT4ELuWIt2No3MX5tkBtdkhsNsCWZP1x7fdUL43yfBVQB9J1QoiXiMx6k /XKVcrrmowU5dqcrXUw2QUIL0uoK7t8AKIKuzntMdpjPwndsW1Hd8l5VpSEP+pr7 qJ7M05/KmUirhnNPYEKhLKM7bH+EBHcT+7F4zP6n8Rc80Itj/jUZAdu8Ojz6o/0+ OjgPaBcZ5Z4Y0F+ErNTQnq6EfdpXQQ1vEP4IhJW+QqA1WYrFUV6YdMVq0toUxBrY Zjr4g51MI2V2ebAli3VSUi5kvsi5LyajWkMOB5C9c3k7G9ceI4+XxBBFcNQA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:date:date:feedback-id :feedback-id:from:from:in-reply-to:in-reply-to:message-id :mime-version:references:reply-to:sender:subject:subject:to:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm3; t=1657233534; x=1657319934; bh=pzEwDxpTkSIX6cxGUKDE8VohgBWp tGlFqLxlQ68bMbA=; b=Uh/IdB/KiQkxrXRFrRk+eARW+aEYsoHV4aIePQVTeHvW P4m6veImPgZ/qEWFrwEBHgjhj/5IeuQcRD3pmuI93LV5D9MaYmrxVqevMGwLaarv Z/SOoFncvLWGShsHciIS+dbRJJzT1l6KWwrAf7IB9UFJ9OTKHKTNePolLw01jzUH upCJeSnVlgmckV2MDi0ntS6VbKs7tH9MZurT41xvsgXD2pvgE/W9gK+eyOZt0Q/E 5wYOzJqgUB1MKdLuorbI6LXyF0n2Rs7vwV04JE54sjZyxUpgs7Oz/V5cfNuDNIOh usx4ws9AlTXr/2f/fRWfs9WTBW3suRj2V/b9s6UsVA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvfedrudeiiedgudduucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne gfrhhlucfvnfffucdljedtmdenucfjughrpeffhffvvefukfhfgggtuggjsehgtdorredt tddvnecuhfhrohhmpefoihgthhgrvghlucfrrghquhhivghruceomhhitghhrggvlhesph grqhhuihgvrhdrgiihiieqnecuggftrfgrthhtvghrnhepffduleehgefhkeefgfeftdfh kedutddvhfdukeeggeehieekffelhfelkeehteefnecuvehluhhsthgvrhfuihiivgeptd enucfrrghrrghmpehmrghilhhfrhhomhepmhhitghhrggvlhesphgrqhhuihgvrhdrgiih ii X-ME-Proxy: Feedback-ID: i0fe9450f:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 7 Jul 2022 18:38:52 -0400 (EDT) Date: Fri, 8 Jul 2022 07:38:49 +0900 From: Michael Paquier To: Julien Rouhaud Cc: Wilm Hoyer , pgsql-hackers@lists.postgresql.org Subject: Re: BUG #17448: In Windows 10, version 1703 and later, huge_pages doesn't work. Message-ID: References: <20220326082408.moh55zuecxjmewnm@jrouhaud> <20220331045908.bm5edcacvymgwwv2@jrouhaud> <20220331080055.hjrrsrd4lxwlt7f5@jrouhaud> <20220331104659.ol6pqe7s3tpkymuk@jrouhaud> <20220331110309.ws25d6dl5yyzprye@jrouhaud> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="xQfbgIyWsumk38l0" Content-Disposition: inline In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --xQfbgIyWsumk38l0 Content-Type: multipart/mixed; boundary="rN0BPY6c219iMVGW" Content-Disposition: inline --rN0BPY6c219iMVGW Content-Type: text/plain; charset=us-ascii Content-Disposition: inline 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 --rN0BPY6c219iMVGW Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v2-0001-Fix-huge_pages-on-current-Windows.patch" Content-Transfer-Encoding: quoted-printable =46rom 9a1450ecbe291cfc92e97f49506db9f443c8cbe9 Mon Sep 17 00:00:00 2001 =46rom: Michael Paquier 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 =3D 0; Size orig_size =3D size; DWORD flProtect =3D PAGE_READWRITE; + DWORD desiredAccess; =20 ShmemProtectiveRegion =3D 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", Get= LastError()); =20 + desiredAccess =3D FILE_MAP_WRITE | FILE_MAP_READ; + + /* Set large pages if wanted. */ + if ((flProtect & SEC_LARGE_PAGES) !=3D 0) + desiredAccess |=3D FILE_MAP_LARGE_PAGES; =20 /* * 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 =3D MapViewOfFileEx(hmap2, FILE_MAP_WRITE | FILE_MAP_READ, 0, = 0, 0, NULL); + memAddress =3D MapViewOfFileEx(hmap2, desiredAccess, 0, 0, 0, NULL); if (!memAddress) ereport(FATAL, (errmsg("could not create shared memory segment: error code %lu", GetL= astError()), --=20 2.36.1 --rN0BPY6c219iMVGW-- --xQfbgIyWsumk38l0 Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEEG72nH6vTowiyblFKnvQgOdbyQH0FAmLHYHkACgkQnvQgOdby QH14Mg//TVz8V6ZLufaX9Ywl/H7lP6duIlrudAsJ/vEXij07u/1aHWs0GP0zqjta HFWgRqD5x9A7qJqU3NIMxE5Zam2JR4hvidIaJjoteaG41DKSodQoBnvvHzZ7XO2J YcVoHEkVSvC7vVBSmhR2J0se+HdswEcQglA1Oz0VVB19byCIe5saHSOe3Fed0qLX 4msCZNunLWC8Sa0wZd4Lg+Biuxk/OErzWEBWrHLYEXZFKbuSQ0Ri6d0ibDCc0qEu j2JYe3e+9ech0FmSMhT4CeLRSXxKgGftJieAHnSTuKAN6O+FGHfIS+uY4Nly/hXq iYVg7UndeXwnsfQ8EmliAXYr6HIH6r6EhdDSrMuOyb4Z/LNKnjauZEdusGtY9NaJ PYpmYhZQ0lvPDipvFdI/TS687Q7aUmj+631A+x7c84YoUyZAGV6xCnfRf+OQ+7Tz TzaO4Lwgs73eoi9hr6QYANE/k9tnDksWa0wCUiPV5V2WJBpDhxXQqbDxRaBPQ66R lf0SzaPxgBbn5naIdREzNs7GoMdirpekmg14/IquGXwiUxrdY1PXV3YcU8kt3dc9 May//6me4/qk+0rv+79XCb73Ekf+ptzeiiQ0/Nu3EXGuJQckuBKPIYjxBIqjcvZp 2VTnVH6GdvP4qMWHFNm6SFQ+PHj1vrqlIa5saGguBFdTRTiUQ5Y= =5kFC -----END PGP SIGNATURE----- --xQfbgIyWsumk38l0--