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 1vd7yc-00EIMQ-0Z for pgsql-hackers@arkaria.postgresql.org; Tue, 06 Jan 2026 14:24:03 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1vd7ya-008ImG-2i for pgsql-hackers@arkaria.postgresql.org; Tue, 06 Jan 2026 14:24:01 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1vd7ya-008Im8-1c for pgsql-hackers@lists.postgresql.org; Tue, 06 Jan 2026 14:24:01 +0000 Received: from lahtoruutu.iki.fi ([2a0b:5c81:1c1::37]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1vd7yY-004Xja-2v for pgsql-hackers@lists.postgresql.org; Tue, 06 Jan 2026 14:24:00 +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 4dlth53RrWz49Q42; Tue, 06 Jan 2026 16:23:49 +0200 (EET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=iki.fi; s=lahtoruutu; t=1767709430; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=9oTmpyDchfUPQ5OqF/2DHvqoc953mMwjWZCirgSwxw0=; b=FLtEgtJcPi1sO+XNhK2zSG4nnkAMAGDX5ZyolXqOQS02UkhATPGq8eqtC+phSoYNReGiDj OTRIHorhyfCYp2gNYdfqykpEDuQVCoZXMExTCZTKMh4bJkb4aOTUTxXCnkJQnedCaw/IYc ENaD8hggs6hK2QGeLvMWhf9sQNRs2h/MCUGDeG2Qfj+BT/ioef3jVD8XJMct5lZkzwBthO 8lvfesHxrwV5w4Y2uUeKyazBj5tb9TY461LVa5g0aJlI0Y2Rk+l89MzOv7ND+pFRHaomP2 QU2zm/Xuf/HAGNYl/QIfdw7lT6HD51KQRUU6b5dUCQnE6YLaqzvxTOT9L++WpQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=iki.fi; s=lahtoruutu; t=1767709430; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=9oTmpyDchfUPQ5OqF/2DHvqoc953mMwjWZCirgSwxw0=; b=D5Hfv7qKpUtxyK+lklpQXk8U3HlFyX4/JfbnS853pK5Tg6DDyVXkPm2EaEDpNQEVlRj42n B3gySlcQNSgFIDPrc9Gf3nKQBaA1P7bed72BQRJ1FdrPUNjIbV3f8QDeiucFVenQEE3DkN KWGZWYhlUwlDrrEoWgGKNosz/ow1NGETY2kkto35rOcyvxfi30tVLlvg4HHTP+lWMWd0cp wbJT9liVKqz8KEmnRbLzk1Hc+Y4MVmNKyPiDzAYKFRghGI2VPwrQ1finYEbqRlq4DEKmY8 IRGt0XVgtiFNYFladRVedkMOL18zPagf+cWwSmkTZsMk7cBhOPJMrMMId73H5Q== 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=1767709430; b=Qm/T91pQD4mHM3fhm4fp/PPk12bQR6BJvW1Wm+u/lM07hIB/8g3II8LVfzyamQYlmmwrcM w7UiAWQ1pSKIUmV6Zne7SK/65tVRsTOVz60WGipvLhjefiROvtuUYmoZy4heleM3q18XZ+ 69dT/hR5E15fCbDMA7ZEATExgGHWxlALXFSFz5X9vZGXqiayBk+vsS6XMxedgEfK1mR/x1 wkgTFPyUrYlcq2DZ39PtIqAtxPX+gTvr2QRohNHc5mdZTO96yXNtN1TWLMN/9THzxCOFRC ZS3KYc07Jcd9oDwnMn4i/HmlPyBrsmQW7ndra2cSzwDl/Gxhwu7fmi5E5ouI+Q== Message-ID: <3d7e7d38-b3c1-4adf-8cb0-309dba08dba9@iki.fi> Date: Tue, 6 Jan 2026 16:23:43 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: Refactor PROCLOCK hash table into partitioned list allocator To: Andrey Borodin , PostgreSQL Hackers References: <271502B5-C950-4428-AF69-9C6D62EF5F14@yandex-team.ru> Content-Language: en-US From: Heikki Linnakangas In-Reply-To: <271502B5-C950-4428-AF69-9C6D62EF5F14@yandex-team.ru> 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 30/12/2025 14:37, Andrey Borodin wrote: > Hi hackers, > > Following up on the Discord discussion about the PROCLOCK hash table being > a "weird allocator" that we never actually use for lookups - I took a stab at > replacing it with a simpler partitioned free list approach as was suggested. > I was doing this mostly to educate myself on Lock Manager internals. > > The current implementation uses LockMethodProcLockHash purely as an allocator. > We never do hash lookups by key; we only allocate entries, link them to the lock's > procLocks list, and free them later. Using a full hash table for this adds > unnecessary complexity and maybe even overhead (I did not measure this). > > The attached patch replaces this with: > - ProcLockArray: A fixed-size array of all PROCLOCK structs (allocated at startup) > - ProcLockFreeList: Partitioned free lists, one per lock partition to reduce contention > - ProcLockAlloc/Free: Simple push/pop operations on the free lists > - PROCLOCK lookup: Linear traversal of lock->procLocks (see LockRefindAndRelease() > and FastPathGetRelationLockEntry()) > > The last point bothers me most. It seems like this traversals are expected to be short. > But I'm not 100% sure. Hmm, yeah the last point contradicts the premise that the hash table is used purely as an allocator. It *is* used for lookups, and you're replacing them with linear scans. That doesn't seem like an improvement. - Heikki