Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1vNHSp-00Fzq5-12 for pgsql-hackers@arkaria.postgresql.org; Sun, 23 Nov 2025 21:17:43 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1vNHSn-00FWyL-2y for pgsql-hackers@arkaria.postgresql.org; Sun, 23 Nov 2025 21:17:42 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1vNHSn-00FWyC-1n for pgsql-hackers@lists.postgresql.org; Sun, 23 Nov 2025 21:17:41 +0000 Received: from fhigh-a2-smtp.messagingengine.com ([103.168.172.153]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1vNHSl-0017FP-1M for pgsql-hackers@lists.postgresql.org; Sun, 23 Nov 2025 21:17:41 +0000 Received: from phl-compute-02.internal (phl-compute-02.internal [10.202.2.42]) by mailfhigh.phl.internal (Postfix) with ESMTP id 9060B1400100; Sun, 23 Nov 2025 16:17:36 -0500 (EST) Received: from phl-mailfrontend-01 ([10.202.2.162]) by phl-compute-02.internal (MEProxy); Sun, 23 Nov 2025 16:17:36 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=burd.me; h=cc:cc :content-transfer-encoding:content-type:content-type:date:date :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to; s=fm1; t=1763932656; x=1764019056; bh=W1FSZ1mMox/yIQByNFO1bUR4W+OGx+3qEa71s2WDJZE=; b= fAb8soY3+FadezU7AZrFN+aTtNbIT2hxr0gFXi9hi4JHUG/hbonXzA3ryKgEMab6 5KCqqfqlNWY9IpPKx6Fu43gkRT9+cWYMhqpKUEFpB9hIQTVVRP3t+URiIMA2iR0f IjOHyF4bYiecvCGOtn1UX/uoee5t5VmxSbjvOOdMtmNITL4VfcN1m6/jM3yxWqLT 6V6cw86aPqZYz24tFLAboSXCJq7GbxgxxaIqMH6Uq3JNCu+owQfIS2cJa2VkbK1f z/Ri7eNjJBjYxW97jUoxeYKXI5rM/ufEfxGU8obv1TmUhiFTij46/KyQ5HmhKOT8 A52k6H769A8ZOxS3423kIA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm3; t=1763932656; x= 1764019056; bh=W1FSZ1mMox/yIQByNFO1bUR4W+OGx+3qEa71s2WDJZE=; b=t KpQbeKxqbSELTvwf2O3F8PcuD2jylwiwCnJv5pQ3FZHr02vKsotp1RiIcOCtEULJ qLbJW96473BhzEkeRRufk3AvpaL/1KfnVnaofTZv0Cpvo4nM+JNCJz6/RoH9F9Ev d5BsOPizCVm/Ln20jfad6DqzZOaiPmTZugggtypXLYl04HQwtRJnHTXrGMxA/fJy uAgSBrdudFDb9ipGZBtGEJHmU6z0JP+ZCN28dJTihqIMcwiClpp4eiWlMbZXEd5S iCEnR6cu0znIxuTlYsHzn6qiIZLJkZVaRlRjX/6wzkXLNHaUVVMhb5DE74Rb1boa 6eZBm2QtduKkhQopUH6Dw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeffedrtdeggddvfeeijeekucetufdoteggodetrf dotffvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfurfetoffkrfgpnffqhgenuceu rghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujf gurhepfffhvfevkfgjfhfuofggtgfgugesthhqmhdtredtjeenucfhrhhomhepifhrvghg uceuuhhrugcuoehgrhgvghessghurhgurdhmvgeqnecuggftrfgrthhtvghrnhepteeuje ehgefhjefgveelleekueelhedtieelteetffetuedvgedvtdeufeejveffnecuffhomhgr ihhnpehsthgrtghkohhvvghrfhhlohifrdgtohhmnecuvehluhhsthgvrhfuihiivgeptd enucfrrghrrghmpehmrghilhhfrhhomhepghhrvghgsegsuhhrugdrmhgvpdhnsggprhgt phhtthhopedvpdhmohguvgepshhmthhpohhuthdprhgtphhtthhopehthhhomhgrshdrmh hunhhrohesghhmrghilhdrtghomhdprhgtphhtthhopehpghhsqhhlqdhhrggtkhgvrhhs sehlihhsthhsrdhpohhsthhgrhgvshhqlhdrohhrgh X-ME-Proxy: Feedback-ID: i675e48f3:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Sun, 23 Nov 2025 16:17:36 -0500 (EST) Date: Sun, 23 Nov 2025 16:17:25 -0500 From: Greg Burd To: Thomas Munro Cc: PostgreSQL Hackers Message-ID: In-Reply-To: References: Subject: Re: Trying out X-Mailer: Mailspring MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Nov 23 2025, at 4:08 pm, Thomas Munro wrote= : > On Mon, Nov 24, 2025 at 4:23=E2=80=AFAM Greg Burd wrot= e: >> As mentioned on a separate thread about fixing ARM64 support when >> building with MSVC on Win11 =5B1=5D I tried out this patch. The reply= on >> that thread had an issue with =5Fmm=5Fpause() in spin=5Fdelay(), it tu= rns >> out we need to use =5F=5Fyield() =5B2=5D. I went ahead and fixed that= , so >> ignore that patch on the other thread =5B1=5D. The new patch attached= >> that layers on top of your work and supports that platform, there was >> one minor change that was required: >> =20 >> =20 >> =23ifdef =5FMSC=5FVER >> =20 >> /* >> * If using Visual C++ on Win64, inline assembly is >> unavailable. Use a >> * =5Fmm=5Fpause intrinsic instead of rep nop. =46or ARM64, us= e the =5F=5Fyield() >> * intrinsic which emits the YIELD instruction as a hint to >> the processor. >> */ >> =23if defined(=5FM=5FARM64) >> =5F=5Fyield(); >> =23elif defined(=5FWIN64) >> =5Fmm=5Fpause(); >> =23else >> /* See comment for gcc code. Same code, MASM syntax */ >> =5F=5Fasm rep nop; >> =23endif >> =23endif /* =5FMSC=5F= VER */ > =20 > That makes more intuitive sense... but I didn't know that people *do* > sometimes prefer instruction synchronisation barriers for spinlock > delays: > =20 > https://stackoverflow.com/questions/70810121/why-does-hintspin-loop-use= -isb-on-aarch64 > =20 > When reading your patch I was pretty confused by that, because it said > it was fixing a barrier problem and apparently doing so in an > unprincipled place. I guess we really need to research the best delay > mechanism for our needs on this architecture, independently of the > compiler being used, and then write matching GCC and Visual Studio > versions of that=3F I think there were some threads about spinlock > performance on Linux + Graviton with graphs and theories... Interesting, I think I was rushing to get past that compile issue rather than optimizing. This sounds like yet another place where we should choose based on arch and it seems hint::spin=5Floop() does. >> tests are passing, best. > =20 > Great news=21 Thanks. It sounds like if I could supply the missing > credible evidence of codegen quality on... all the computers, then I > think we'd be down to just: when can we pull the trigger and require > Visual Studio 2022 and do we trust /experimental:c11atomics=3F I'm in favor of the stdatomic approach. I can't speak to codegen quality on *all the platforms* or how *experimental* c11 atomics are when using MSVC. > =46TR I had earlier shared some version of this patch with Dave when he= > was trying to get his Windows/ARM system going, but I think my earlier > version was probably too broken. Sorry Dave. At that stage I was > also trying to do it as an option but keeping the existing stuff > around. Since then we adopted C11, so this is the all-in version. I > also hadn't understood a key part of the C11 memory model that your > RISC-V animal taught me and that c5d34f4a fixed, and you can see in > this patch set too, and I'm not sure if Visual Studio is like GCC or > Clang in that respect. Thanks for that work on RISC-V, I appreciate that=21 Much more digging t= o be done to answer those questions for sure. > It crossed my mind that this might even be > related to the problem you've noticed with barriers being missing, but > I haven't looked into that. BTW I believe we could actually change > our code NOT to rely on that, ie to follow the C11 memory model better > and declare eg PgAioHandle::status as atomic=5Fuint8 or whatever (other= > non-atomic access would be considered dependent and do the right thing > IIUC), but I'm not sure if it's necessary and that research project > can wait. Interesting. Yeah, let's do one thing and then move to the next, but I do like the idea. best. -greg