From patchwork Fri Nov 17 11:35:34 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christopher Baines X-Patchwork-Id: 56587 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id A1E0127BBEA; Fri, 17 Nov 2023 11:36:25 +0000 (GMT) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-2.9 required=5.0 tests=BAYES_00,MAILING_LIST_MULTI, SPF_HELO_PASS autolearn=unavailable autolearn_force=no version=3.4.6 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id 314FD27BBE2 for ; Fri, 17 Nov 2023 11:36:25 +0000 (GMT) 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 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+patchwork=mira.cbaines.net@gnu.org Sender: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org X-getmail-retrieved-from-mailbox: Patches 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(-) base-commit: e35b7c5386c1bfacf47ed31bac9b503373dd26fc 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)))