From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: <gentoo-commits+bounces-1385214-garchives=archives.gentoo.org@lists.gentoo.org> Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id 2937115808B for <garchives@archives.gentoo.org>; Wed, 13 Apr 2022 15:34:43 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 5D01DE0A46; Wed, 13 Apr 2022 15:34:42 +0000 (UTC) Received: from smtp.gentoo.org (dev.gentoo.org [IPv6:2001:470:ea4a:1:5054:ff:fec7:86e4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 43D89E0A46 for <gentoo-commits@lists.gentoo.org>; Wed, 13 Apr 2022 15:34:42 +0000 (UTC) Received: from oystercatcher.gentoo.org (oystercatcher.gentoo.org [148.251.78.52]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 64F84341DD2 for <gentoo-commits@lists.gentoo.org>; Wed, 13 Apr 2022 15:34:41 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id E6DE53A5 for <gentoo-commits@lists.gentoo.org>; Wed, 13 Apr 2022 15:34:39 +0000 (UTC) From: "Sam James" <sam@gentoo.org> To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Sam James" <sam@gentoo.org> Message-ID: <1649864070.05c0b3d03393fe376f3ae4b49bce403d496e3e68.sam@gentoo> Subject: [gentoo-commits] proj/portage:master commit in: lib/portage/dbapi/ X-VCS-Repository: proj/portage X-VCS-Files: lib/portage/dbapi/vartree.py X-VCS-Directories: lib/portage/dbapi/ X-VCS-Committer: sam X-VCS-Committer-Name: Sam James X-VCS-Revision: 05c0b3d03393fe376f3ae4b49bce403d496e3e68 X-VCS-Branch: master Date: Wed, 13 Apr 2022 15:34:39 +0000 (UTC) Precedence: bulk List-Post: <mailto:gentoo-commits@lists.gentoo.org> List-Help: <mailto:gentoo-commits+help@lists.gentoo.org> List-Unsubscribe: <mailto:gentoo-commits+unsubscribe@lists.gentoo.org> List-Subscribe: <mailto:gentoo-commits+subscribe@lists.gentoo.org> List-Id: Gentoo Linux mail <gentoo-commits.gentoo.org> X-BeenThere: gentoo-commits@lists.gentoo.org X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply X-Archives-Salt: 1dd0df62-a8d1-4eae-a55b-172cd437e8a3 X-Archives-Hash: 1ad5658529cfe33c17a0e7f34e807160 commit: 05c0b3d03393fe376f3ae4b49bce403d496e3e68 Author: Mike Frysinger <vapier <AT> chromium <DOT> org> AuthorDate: Tue Mar 29 07:12:25 2022 +0000 Commit: Sam James <sam <AT> gentoo <DOT> org> CommitDate: Wed Apr 13 15:34:30 2022 +0000 URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=05c0b3d0 vartree: avoid lock contention when there are no blockers No sense in grabbing the vdb lock if we aren't going to do any work. This avoids contention on the global lock with parallel packages. [sam: cherry-picked from chromiumos' third_party/portage_tool repo] (cherry picked from commit ea5f6f8c0a5e05d7630f9070992a89fa6907cc14) Signed-off-by: Sam James <sam <AT> gentoo.org> Closes: https://github.com/gentoo/portage/pull/813 Signed-off-by: Sam James <sam <AT> gentoo.org> lib/portage/dbapi/vartree.py | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/lib/portage/dbapi/vartree.py b/lib/portage/dbapi/vartree.py index e7252790d..602913862 100644 --- a/lib/portage/dbapi/vartree.py +++ b/lib/portage/dbapi/vartree.py @@ -5148,14 +5148,17 @@ class dblink: self._clear_contents_cache() contents = self.getcontents() destroot_len = len(destroot) - 1 - self.lockdb() - try: - for blocker in blockers: - self.vartree.dbapi.removeFromContents( - blocker, iter(contents), relative_paths=False - ) - finally: - self.unlockdb() + + # Avoid lock contention if we aren't going to do any work. + if blockers: + self.lockdb() + try: + for blocker in blockers: + self.vartree.dbapi.removeFromContents( + blocker, iter(contents), relative_paths=False + ) + finally: + self.unlockdb() plib_registry = self.vartree.dbapi._plib_registry if plib_registry: