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 1vVnnD-008Cjb-0O for pgsql-hackers@arkaria.postgresql.org; Wed, 17 Dec 2025 09:25:59 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1vVnnC-00Bf98-0G for pgsql-hackers@arkaria.postgresql.org; Wed, 17 Dec 2025 09:25:58 +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 1vVnnB-00Bf90-2a for pgsql-hackers@lists.postgresql.org; Wed, 17 Dec 2025 09:25:58 +0000 Received: from lahtoruutu.iki.fi ([185.185.170.37]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1vVnnA-001Cbi-12 for pgsql-hackers@postgresql.org; Wed, 17 Dec 2025 09:25:58 +0000 Received: from [10.0.2.15] (unknown [130.41.208.2]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange x25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: hlinnaka) by lahtoruutu.iki.fi (Postfix) with ESMTPSA id 4dWT1V682fz49PyQ; Wed, 17 Dec 2025 11:25:50 +0200 (EET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=iki.fi; s=lahtoruutu; t=1765963551; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=kGG6X+lhhGXVm1LE/mOczzYi6Y2/UchpBcwGJZqpOLQ=; b=pzrIN3YNPYqg8tnrBBSN1JOqhfWGGm73FTOuA3zAUyFz+BHqEHYKw/WhZpWGy0sqxQoFJL TMGqgLobgWxMR82mAE7+ZLihwIHyd3DfYXCIwJEAfPxCh6i39VWf0tiqYWPftwBy1rm0ED enyGa6ZG1OuhNAfpyXfPBhvItzC1YPWazTFK6kbjmkAHJlrk5ZPHTBhLl/VlryMljwlIXw d3JT+1W8iaj6EaJJ+65Nz3NQxDAcIBNzrlXoCYSdIptoL2HnegGI2/izq7lXWOadncEqy5 3F5XfmLJwE9Z7nM6MXU5mR8OVRzIHnf5Eyed/Dp+P6Obn2E6P81lfh4JqVEHMQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=iki.fi; s=lahtoruutu; t=1765963551; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=kGG6X+lhhGXVm1LE/mOczzYi6Y2/UchpBcwGJZqpOLQ=; b=RAMe8lPg3FV6RPpS4LJZtfgUnR57mtiJMhvdVLUl5bZZQUaFAmqSawu2i7ila1EfcoSuXE o+02awZXMhUKkD12XIo09pJQNQmGGznDOIzqSt8NYZ2pNDEy2HCPotKt7Fpm0kiqkYX3XM GMUZ0JugGb8Kcrn/DuslVJVX2zG44S/KaZCjmTfdgrO9lOCcQMJYh9Xi1LuBQBL9/jtpHx 7P0erIusafdwYF/FNgANaJMbEatQ5pCVq8BZKJEd/6OW285KA+KeUhphzIGLyHIKPtOEra y6ZU0RvbwW4dsz/7aH1HeXqkNhKrLr5Q48z4l+Iy77ZfFkMnEuVv6q4UNWFVMQ== ARC-Authentication-Results: i=1; ORIGINATING; auth=pass smtp.auth=hlinnaka smtp.mailfrom=hlinnaka@iki.fi ARC-Seal: i=1; a=rsa-sha256; d=iki.fi; s=lahtoruutu; cv=none; t=1765963551; b=kY7/qoiWcPDkDhzx6FTS2dh9IPD4by7cW+SoetoUsxf0zTGjzNiEWPapEcsIWmpCDWh5HL H1lB0/+iHtGEdoevUONOUqFaza+R+rxwhD4cx1gmtnLnqtfAS9pzNN4tNqdg5GKKUSsxz5 9ssIS0RW8VV2lDZUzu0m7z70Ieb7QKkgJiWzqVxhl9vYUP2ZVHfPb6SrIZPWokOZgWaQ1x zwiPzBAp2f5pCw7YcZtfiInn5/7eDO02xdRmlQHaKtbUzfYjpA167haOzJnPrjwc7gxWv7 BY2OZJGVsymUtclqX9qxfEYg8jDmpg3VWdzjmy9EXyyuawVblM9KGwRqkikMcA== Message-ID: Date: Wed, 17 Dec 2025 11:25:50 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: Buffer locking is special (hints, checksums, AIO writes) To: Andres Freund , Melanie Plageman Cc: Matthias van de Meent , pgsql-hackers@postgresql.org, Thomas Munro , Noah Misch , Robert Haas , Michael Paquier References: <6kmid26do57ykqfpvq6iieniy4djsymhrypkjccazq5g4bbe6a@2y6owwv7qpex> <3je3ahgf7rrmmurxo6hnlhg5d3ffwfrtjwjxd6jm5srlv5iebp@vxqk5qtgmowr> <3w7v3w6a57jnssokap4k7thoekig72flnyhd4wp3yftzdd7lm7@f6lpcfen6hr7> <6rgb2nvhyvnszz4ul3wfzlf5rheb2kkwrglthnna7qhe24onwr@vw27225tkyar> <3nce7i72ayzkunai6mkz24ckbxk74jodz4ua2chcdrwppxlxcd@w6x5kfkjrkru> Content-Language: en-US From: Heikki Linnakangas In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 03/12/2025 02:47, Andres Freund wrote: > On 2025-11-25 11:54:00 -0500, Andres Freund wrote: >> Thanks a lot for that detailed review! A few questions and comments, before I >> try to address the comments in the next version. > > Here's that new new version, with the following changes > > - Some more micro-optimizations, most importantly adding a commit that doesn't > initialize the delay in LockBufHdr() unless needed. With those I don't see a > consistent slowdown anymore (slight speedup on one workstation, slight > slowdown on another, in an absurdly adverse workload) +1 I'm comparing the patched LockBufHdr() with LWLockWaitListLock(), which does pretty much the same thing, and LWLockWaitListLock() already did the initialization of the delay that way. But there are some small differences: - LockBufHdr() uses unlikely() in the initial attempt, LWLockWaitListLock() does not - LWLockWaitListLock() uses pg_atomic_read_u32() after spinning, LockBufHdr() retries directly with pg_atomic_fetch_or_u32(). Are there reasons for the differences, or is it just that they were developed separately and ended up looking slightly different? - Heikki