From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp10.migadu.com ([2001:41d0:403:58f0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms8.migadu.com with LMTPS id MEGiHjlQV2VNEQEAG6o9tA:P1 (envelope-from ) for ; Fri, 17 Nov 2023 12:36:25 +0100 Received: from aspmx1.migadu.com ([2001:41d0:403:58f0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp10.migadu.com with LMTPS id MEGiHjlQV2VNEQEAG6o9tA (envelope-from ) for ; Fri, 17 Nov 2023 12:36:25 +0100 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id E02CC1549E for ; Fri, 17 Nov 2023 12:36:24 +0100 (CET) Authentication-Results: aspmx1.migadu.com; dkim=none; dmarc=none; spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org" ARC-Seal: i=1; s=key1; d=yhetil.org; t=1700220985; a=rsa-sha256; cv=none; b=XFFz+t5Ydj/bAOSsoqfKgWbn9MQPUKCpU545pkTRxLgM+gUEw5y7tcwnNh4KMolkMxVgax aToDvfgjvJkWbN1rC1n2dZs1ocP6xCYwC6LLT/Rngf6dLe+ExoqENjgSXliIMUe0d3lLUA 1QjQfirQ4BQc+IdB92GxMnb5ak+Oc50+LWP99KThpTQ92/bMXcz9BqxvSOltcNUJWaKBkx cQ+oSLkDVsctW/QPBvKIAV3p9eVpTv7XORBzdMAh9JtaaHtg+zDGxKuOCYBwEGstlC3DEG sE7A14R9eoicjMsyXOZevx/bZFaWX5zRRebDqVrj9ZIaSi8NdzJk+dU51TVoxQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1700220985; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding:resent-cc: resent-from:resent-sender:resent-message-id:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=lCZeMPhkPc1bOBTY8ADufXcSVx0o18pQkFynEZ8V9vY=; b=G2pv/MBK2Um559qBtcUlgmzfVuCBZ6Z8AoDm8BNyzZp4NlhmCm2ZHE1v08v5KXDhPAPEI0 SqZXu6KnN8AZS6itPxKn7AZQmfQCi/PNf5iGU0gbVKURUTCzybTkDoz8xTxA8KMoUbxS9V eFv5sB4M8L2x7FCIIBkTISkI4faNtgg8Fc1xBkEoMOb4dsv2DTJ6zAQSsDSJMB2olcZ10b J9iLY9WMrF1lzIEKZMzI445EU5plbkJNItrVUIi72nnznF56+MOllupV85fJ6Pnah4tyfl +lOebyCIhUVG6an6HTPMW3ajE2WhWtPhzOGvYGO3X/I8S9WwYrB4uMSpTa9imQ== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=none; dmarc=none; spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org" Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1r3x8s-0000vU-FZ; Fri, 17 Nov 2023 06:36:10 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1r3x8o-0000v8-O1 for guix-patches@gnu.org; Fri, 17 Nov 2023 06:36:06 -0500 Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1r3x8n-0003vJ-7R; Fri, 17 Nov 2023 06:36:05 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1r3x8k-0003Ok-FG; Fri, 17 Nov 2023 06:36:02 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#67238] [PATCH] derivations: Avoid readlink syscalls in read-derivation-from-file. Resent-From: Christopher Baines Original-Sender: "Debbugs-submit" Resent-CC: guix@cbaines.net, dev@jpoiret.xyz, ludo@gnu.org, othacehe@gnu.org, rekado@elephly.net, zimon.toutoune@gmail.com, me@tobias.gr, guix-patches@gnu.org Resent-Date: Fri, 17 Nov 2023 11:36:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 67238 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 67238@debbugs.gnu.org Cc: Christopher Baines , Josselin Poiret , Ludovic =?UTF-8?Q?Court=C3=A8s?= , Mathieu Othacehe , Ricardo Wurmus , Simon Tournier , Tobias Geerinckx-Rice X-Debbugs-Original-To: guix-patches@gnu.org X-Debbugs-Original-Xcc: Christopher Baines , Josselin Poiret , Ludovic =?UTF-8?Q?Court=C3=A8s?= , Mathieu Othacehe , Ricardo Wurmus , Simon Tournier , Tobias Geerinckx-Rice Received: via spool by submit@debbugs.gnu.org id=B.170022095913047 (code B ref -1); Fri, 17 Nov 2023 11:36:02 +0000 Received: (at submit) by debbugs.gnu.org; 17 Nov 2023 11:35:59 +0000 Received: from localhost ([127.0.0.1]:45431 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1r3x8h-0003OL-1t for submit@debbugs.gnu.org; Fri, 17 Nov 2023 06:35:59 -0500 Received: from lists.gnu.org ([2001:470:142::17]:48978) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1r3x8c-0003Ns-80 for submit@debbugs.gnu.org; Fri, 17 Nov 2023 06:35:58 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1r3x8R-0000uH-2x for guix-patches@gnu.org; Fri, 17 Nov 2023 06:35:47 -0500 Received: from mira.cbaines.net ([212.71.252.8]) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1r3x8O-0003Se-Jf for guix-patches@gnu.org; Fri, 17 Nov 2023 06:35:42 -0500 Received: from localhost (unknown [217.155.61.229]) by mira.cbaines.net (Postfix) with ESMTPSA id 8D8A427BBE2 for ; Fri, 17 Nov 2023 11:35:35 +0000 (GMT) Received: from localhost (localhost [local]) by localhost (OpenSMTPD) with ESMTPA id 6d79035a for ; Fri, 17 Nov 2023 11:35:34 +0000 (UTC) From: Christopher Baines Date: Fri, 17 Nov 2023 11:35:34 +0000 Message-ID: X-Mailer: git-send-email 2.41.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Received-SPF: pass client-ip=212.71.252.8; envelope-from=mail@cbaines.net; helo=mira.cbaines.net X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01, UNPARSEABLE_RELAY=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+larch=yhetil.org@gnu.org Sender: guix-patches-bounces+larch=yhetil.org@gnu.org X-Migadu-Flow: FLOW_IN X-Migadu-Country: US X-Migadu-Scanner: mx11.migadu.com X-Spam-Score: -3.09 X-Migadu-Queue-Id: E02CC1549E X-Migadu-Spam-Score: -3.09 X-TUID: 5AlgQw34QtS3 strace -c reports over 10,000 readlink syscalls when reading the derivation for the hello package. By just setting the %file-port-name-canonicalization fluid, this drops to less than 10. I'm not sure if this actually improves performance, but doing less is surely better. * guix/derivations.scm (read-derivation-from-file): Set %file-port-name-canonicalization to 'none when calling call-with-input-file. Change-Id: I1ff16a059160576a576f2e9ed881379596e66af3 --- guix/derivations.scm | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/guix/derivations.scm b/guix/derivations.scm index 9fec7f4f0b..e6ecb570c4 100644 --- a/guix/derivations.scm +++ b/guix/derivations.scm @@ -556,7 +556,12 @@ (define (read-derivation-from-file file) ;; and because the same argument is read more than 15 times on average ;; during something like (package-derivation s gdb). (or (and file (hash-ref %derivation-cache file)) - (let ((drv (call-with-input-file file read-derivation))) + (let ((drv + ;; Avoid calling scm_i_relativize_path in + ;; fport_canonicalize_filename since this leads to lots of + ;; readlink calls + (with-fluids ((%file-port-name-canonicalization 'none)) + (call-with-input-file file read-derivation)))) (hash-set! %derivation-cache file drv) drv))) base-commit: e35b7c5386c1bfacf47ed31bac9b503373dd26fc -- 2.41.0