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 1nZmtx-0006PS-2C for pgsql-bugs@arkaria.postgresql.org; Thu, 31 Mar 2022 04:59:17 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1nZmtv-00022t-Vm for pgsql-bugs@arkaria.postgresql.org; Thu, 31 Mar 2022 04:59:15 +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 1nZmtv-00022j-No for pgsql-bugs@lists.postgresql.org; Thu, 31 Mar 2022 04:59:15 +0000 Received: from mail-pg1-x530.google.com ([2607:f8b0:4864:20::530]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1nZmtt-0000uH-MA for pgsql-bugs@lists.postgresql.org; Thu, 31 Mar 2022 04:59:15 +0000 Received: by mail-pg1-x530.google.com with SMTP id t4so16049313pgc.1 for ; Wed, 30 Mar 2022 21:59:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=a/Ds8icmJyZuCq4CgQmNA0mcJkZyt6Yn6iY3CQra1A4=; b=g36bhQPlplZndeH4ivkDCER+GoFej0mUauYhtrNeQbO96BYS9sxqq2dhMvmWcQGvK3 salrg1Vd5upRpNQvwB/D6PonP6LJL+1iLJ7EUATMpf/MSBaeFQ2S1TMgxNQymGXYl53j YxE1ipjjS1jbBkoI/h4qhtz/Si28t47ES20TFMdhuaNLpET2j2Soxj8+cqHMkeIJmxa9 7sWUP1DsexrgvQN1FliScy0DX9NfNJ/iL8dXWa5JD36x2rXXOat6ksCFKblN2cAHFjz8 hfDEc//bAFKThEzQtfD4ao6mJafPvt+4R3avmH2T9AoPQNU/0ZKUjFW+R3loRK5R0JQF j/Gw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=a/Ds8icmJyZuCq4CgQmNA0mcJkZyt6Yn6iY3CQra1A4=; b=67zkdhmISF4iDXLc4OkpO+w90tQs2ipv4VdYCr64c1x/4S4bje4QpYmejO/494zcQh BESJ+iLHiAb7gc79InbFq+lSsViE9BfWTzBZWcssvMpV9NHQxz6cX59qXqLQ7fcy0ikj jXf7fCssDRdV5C+Bg+M4A3gs4ZxhDNswFwjxLR09iujIafMVyuGzfU3ZeZ84cKwnusKG GYXT7PpcGda6lmeQX/kgG4UjJMEw5cm7vosb7zzHvtDIJCEQgOjbdw2JFDP3N0lG7h4R vnZRSC1dAK0ZS2pK8UlzElpyqImGSVZTefsQit9jVQoTr/0gayvQtVGoC9ciw/W4++Zc VEwg== X-Gm-Message-State: AOAM532KyPi8nCzPRHuL1VhURY6FV7jpKFAEjlamPVk4/LdJJ6jH5QrQ +WQ0PzIX+Z+oBFNI0jq85GI= X-Google-Smtp-Source: ABdhPJxwyXRZ3ApO4UeyeI+4f9FZv/L1uX3bxz8uT4i0StH4na0NezI/ycfJWpY9Q1QLdOBAy3OfJg== X-Received: by 2002:a05:6a00:26cf:b0:4f6:fc52:7b6a with SMTP id p15-20020a056a0026cf00b004f6fc527b6amr3463500pfw.39.1648702751969; Wed, 30 Mar 2022 21:59:11 -0700 (PDT) Received: from jrouhaud (2001-b011-1005-b35e-8420-3e61-3201-4aba.dynamic-ip6.hinet.net. [2001:b011:1005:b35e:8420:3e61:3201:4aba]) by smtp.gmail.com with ESMTPSA id qe15-20020a17090b4f8f00b001c6f4991cd4sm8210312pjb.45.2022.03.30.21.59.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 30 Mar 2022 21:59:11 -0700 (PDT) Date: Thu, 31 Mar 2022 12:59:08 +0800 From: Julien Rouhaud To: Michael Paquier Cc: Thomas Munro , okano.naoki@jp.fujitsu.com, PostgreSQL mailing lists Subject: Re: BUG #17448: In Windows 10, version 1703 and later, huge_pages doesn't work. Message-ID: <20220331045908.bm5edcacvymgwwv2@jrouhaud> References: <17448-0a96583a67edb1f7@postgresql.org> <20220326082408.moh55zuecxjmewnm@jrouhaud> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Hi, On Wed, Mar 30, 2022 at 04:54:50PM +0900, Michael Paquier wrote: > On Sun, Mar 27, 2022 at 12:07:57AM +1300, Thomas Munro wrote: > > There are traces of method to the madness: It's basically YYMM, but > > then after 2004 they switched to H1 and H2 (first/second half of the > > year) instead of MM, perhaps to avoid confusion with YYYY format year. > > Note also that Windows 10 has a 21H2 and Windows 11 has a 21H2. > > > > Some question I have: is FILE_MAP_LARGE PAGES a macro? We claim to > > support all those ancient zombie OSes like Windows 7, or maybe it's > > even XP for 11, and this has to be back-patched to 11, so we might > > need to make it conditional. But conditional on what? For example, > > does something like the attached work (untested)? What happens if a < > > 1703 kernel sees this flag, does it reject it or ignore it? > > I don't have an answer about how much Windows gets angry if we pass > down to MapViewOfFileEx() the flag FILE_MAP_LARGE_PAGES when running > the code on a version of Windows that does not support it. No idea either, and I don't have old enough Windows machine available to try. > Anyway, I think that we could just play it safe. See for example the > attached, where I use PG_FILE_MAP_LARGE_PAGES at compile time to find > if the value is set. Then, at run-time, I am just relying on > IsWindowsVersionOrGreater() to do the job, something useful when > huge_pages=on as I guess we should fail hard if we did not know about > FILE_MAP_LARGE_PAGES at compile-time, but try to use huge pages at run > time with version >= 10.0.1703. That approach seems sensible. For reference the versionhelpers.h seems to be available starting with VS 2013 / v120, which is ok since that the oldest version we support AFAICS. After *a lot of time* I could finally test this patch. For the record I could never find a way to allow 'Lock pages in memory' on the Windows 10 home I have, so I tried on my Windows 11 evaluation I also had around (version 21H2, so it should be recent enough). For the record on this one there was gpedit available, but then I got a 1450 error, and didn't find any information on how to reserve huge pages or something like that on Windows. So I just configured shared_buffers to 10MB, which should still be big enough to need multiple huge pages, and it seems to work: postgres=# select version(); version --------------------------------------------------------------- PostgreSQL 15devel, compiled by Visual C++ build 1929, 64-bit (1 row) postgres=# show huge_pages; huge_pages ------------ on (1 row) Now, I also have the exact same result without the patch applied so it's hard to know whether it had any impact at all. Unfortunately, I didn't find any information on how to check if "large pages" are used and/or by which program.