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 1njjDS-0000Ry-9U for pgsql-hackers@arkaria.postgresql.org; Wed, 27 Apr 2022 15:04:30 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1njjDR-0002Tt-25 for pgsql-hackers@arkaria.postgresql.org; Wed, 27 Apr 2022 15:04:29 +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 1njjDQ-0002TR-N8 for pgsql-hackers@lists.postgresql.org; Wed, 27 Apr 2022 15:04:28 +0000 Received: from mail.dental-vision.de ([82.144.34.210]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1njjDO-0007aS-7j for pgsql-hackers@lists.postgresql.org; Wed, 27 Apr 2022 15:04:28 +0000 Received: from MAIL.cf.local (2001:9e8:e935:6000:58c6:ffce:82d9:8a35) by Mail.cf.local (2001:9e8:e935:6000:58c6:ffce:82d9:8a35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.6; Wed, 27 Apr 2022 17:04:24 +0200 Received: from MAIL.cf.local ([192.168.169.216]) by Mail.cf.local ([192.168.169.216]) with mapi id 15.01.2507.006; Wed, 27 Apr 2022 17:04:24 +0200 From: Wilm Hoyer To: Michael Paquier , Julien Rouhaud CC: "pgsql-hackers@lists.postgresql.org" Subject: AW: BUG #17448: In Windows 10, version 1703 and later, huge_pages doesn't work. Thread-Topic: BUG #17448: In Windows 10, version 1703 and later, huge_pages doesn't work. Thread-Index: AQHYQLLari2s00oie0yrcUkVcNdgtqzRF5eAgAAr+QCAAC3FgIAGApsAgAFhPgCAAC2tgIAABR2AgAAuZoCAAASEgIABhzwQgCbuaICAAcnTAIAAPCWg Date: Wed, 27 Apr 2022 15:04:23 +0000 Message-ID: <9178d683d05d420a887369ffb38d8fbd@dental-vision.de> References: <20220326082408.moh55zuecxjmewnm@jrouhaud> <20220331045908.bm5edcacvymgwwv2@jrouhaud> <20220331080055.hjrrsrd4lxwlt7f5@jrouhaud> <20220331104659.ol6pqe7s3tpkymuk@jrouhaud> <20220331110309.ws25d6dl5yyzprye@jrouhaud> In-Reply-To: Accept-Language: de-DE, en-US Content-Language: de-DE X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [192.168.169.196] Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Tue, Apr 26, 2022 at 12:54:35PM +0800, Julien Rouhaud wrote: >> I searched a bit and apparently some people are using this function=20 >> directly opening some dll, which seems wrong. > I was wondering about this whole business, and the manifest approach is a= *horrible* design for an API where the goal is to know if your run-time en= vironment is greater than a given threshold. Agreed for the use case at hand, where you want to use one core API Functio= n or another depending on the OS Version. One Blog from Microsoft, I remember, told that one reason for the change we= re the increase of false installation error messages "Install Error - Your = system does not meet the minimum supported operating system and service pac= k level." where the software in question was written for Windows XP and the user trie= d to install it on, say, Windows 8. That is just a Developer-Pilot error, where the Developers forgot to antici= pate future OS Versions and instead of checking for Version at least, where= checking for Version equality of all at design time known Windows Version. Since you can develop only against OS APIs known at design time, and Micros= oft claims to be pretty good at maintaining backward compatible facades for= their APIs, there is some reason in that decision. (To only see the Versions and APIs you told the OS with the manifest, you k= new about at compile time). The core Problem at hand is, that ms broke the promise of backward compatib= ility, since the function in question is working differently, depending on = windows version, although with the above reasoning we should get the exact = same behavior on windows 10 as on windows 8.1 (as PostgreSql, per default, = only claims to know about Windows 8.1 features). That said, I can understand the design decision. Personally, I still don't = like it a bit, since developers should be allowed to make some stupid mista= kes. >>> Another Idea on windows machines would be to use the commandline to=20 >>> execute ver in a separate Process and store the result in a file. >>=20 >> That also seems hackish, I don't think that we want to rely on=20 >> something like that. >Hmm. That depends on the dependency set, I guess. We do that on Linux at= some extent to for large pages in sysv_shmem.c. Perhaps this could work f= or Win10 if this avoids the extra loopholes with the >manifests. I used the following hack to get the "real" Major and Minor Version of Wind= ows - it's in C# (.Net) and needs to be adjusted (you can compile as x64 an= d use a long-long as return value ) to return the Service Number too and tr= anslated it into C. I share it anyways, as it might help - please be kind, as it really is a li= ttle hack. Situation:=20 Main Application can't or is not willing to add a manifest file into its re= sources. Solution: Start a small executable (which has a manifest file compiled into its resou= rces), let it read the OS Version and code the Version into its return Code= . CInt32 is basically an integer redefinition, where one can access the lower= and higher Int16 separately. The Main Programm eventually calls this (locate the executable, adjust the = Process startup to be minimal, call the executable as separate process and = interpret the return value as Version): private static Version ReadModernOsVersionInternal() { String codeBase =3D Assembly.GetExecutingAssembly().CodeBase; Uri uri =3D new Uri(codeBase); String localPath =3D uri.LocalPath; String pathDirectory =3D Path.GetDirectoryName(localPath); if (pathDirectory !=3D null) { String fullCombinePath =3D Path.Combine(pathDirectory, "Cf.Utilitie= s.ReadModernOSVersion"); ProcessStartInfo processInfo =3D new ProcessStartInfo { FileName =3D fullCombinePath, CreateNoWindow =3D true, UseShellExecute =3D false }; Process process =3D new Process { StartInfo =3D processInfo }; process.Start(); if (process.WaitForExit(TimeSpan.FromSeconds(1).Milliseconds)) { CInt32 versionInteger =3D process.ExitCode; return new Version(versionInteger.HighValue, versionInteger.Low= Value); } } return new Version(); } The small Version Check executable: static Int32 Main(String[] args) { return OsVersionErmittler.ErmittleOsVersion(); } and static class OsVersionErmittler { /// /// Ermittelt die OsVersion und =FCbergibt diese als High und LowWord. /// /// public static CInt32 ErmittleOsVersion() { OperatingSystem version =3D Environment.OSVersion; if (version.Platform =3D=3D PlatformID.Win32NT && version.Version >= =3D new Version(6, 3)) { String versionString =3D version.VersionString; return new CInt32((Int16) version.Version.Major, (Int16) versio= n.Version.Minor); } return 0; } } The shortened manifest of the small executable: I hope I'm not intrusive, otherwise, feel free to ignore this mail, Wilm.