Message ID | a0061470c9d839f1503fea238c5e3b3ed92fd660.1700220934.git.mail@cbaines.net |
---|---|
State | New |
Headers |
Return-Path: <guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org> 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 <patchwork@mira.cbaines.net>; 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 <guix-patches-bounces@gnu.org>) 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 <Debian-debbugs@debbugs.gnu.org>) 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 <Debian-debbugs@debbugs.gnu.org>) 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 <Debian-debbugs@debbugs.gnu.org>) 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 <mail@cbaines.net> Original-Sender: "Debbugs-submit" <debbugs-submit-bounces@debbugs.gnu.org> 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: <handler.67238.B.170022095913047@debbugs.gnu.org> 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 <guix@cbaines.net>, Josselin Poiret <dev@jpoiret.xyz>, Ludovic =?utf-8?q?Court=C3=A8s?= <ludo@gnu.org>, Mathieu Othacehe <othacehe@gnu.org>, Ricardo Wurmus <rekado@elephly.net>, Simon Tournier <zimon.toutoune@gmail.com>, Tobias Geerinckx-Rice <me@tobias.gr> X-Debbugs-Original-To: guix-patches@gnu.org X-Debbugs-Original-Xcc: Christopher Baines <guix@cbaines.net>, Josselin Poiret <dev@jpoiret.xyz>, Ludovic =?utf-8?q?Court=C3=A8s?= <ludo@gnu.org>, Mathieu Othacehe <othacehe@gnu.org>, Ricardo Wurmus <rekado@elephly.net>, Simon Tournier <zimon.toutoune@gmail.com>, Tobias Geerinckx-Rice <me@tobias.gr> 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 <debbugs-submit-bounces@debbugs.gnu.org>) 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 <mail@cbaines.net>) 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 <mail@cbaines.net>) 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 <mail@cbaines.net>) 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 <guix-patches@gnu.org>; Fri, 17 Nov 2023 11:35:35 +0000 (GMT) Received: from localhost (localhost [local]) by localhost (OpenSMTPD) with ESMTPA id 6d79035a for <guix-patches@gnu.org>; Fri, 17 Nov 2023 11:35:34 +0000 (UTC) From: Christopher Baines <mail@cbaines.net> Date: Fri, 17 Nov 2023 11:35:34 +0000 Message-ID: <a0061470c9d839f1503fea238c5e3b3ed92fd660.1700220934.git.mail@cbaines.net> 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: <guix-patches.gnu.org> List-Unsubscribe: <https://lists.gnu.org/mailman/options/guix-patches>, <mailto:guix-patches-request@gnu.org?subject=unsubscribe> List-Archive: <https://lists.gnu.org/archive/html/guix-patches> List-Post: <mailto:guix-patches@gnu.org> List-Help: <mailto:guix-patches-request@gnu.org?subject=help> List-Subscribe: <https://lists.gnu.org/mailman/listinfo/guix-patches>, <mailto:guix-patches-request@gnu.org?subject=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 |
Series |
[bug#67238] derivations: Avoid readlink syscalls in read-derivation-from-file.
|
|
Commit Message
Christopher Baines
Nov. 17, 2023, 11:35 a.m. UTC
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
Comments
Hi, Christopher Baines <mail@cbaines.net> skribis: > 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 [...] > + (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)))) This is already done in ‘run-guix’ in (guix ui), for all the ‘guix’ commands (so this patch would be a slight performance regression for Guix itself). I’d suggest setting this fluid globally in applications that use Guix (the Build Coordinator, etc.), as is done in Guix itself. WDYT? Ludo’.
Ludovic Courtès <ludo@gnu.org> writes: > Hi, > > Christopher Baines <mail@cbaines.net> skribis: > >> 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 > > [...] > >> + (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)))) > > This is already done in ‘run-guix’ in (guix ui), for all the ‘guix’ > commands (so this patch would be a slight performance regression for > Guix itself). > > I’d suggest setting this fluid globally in applications that use Guix > (the Build Coordinator, etc.), as is done in Guix itself. > > WDYT? Ah, I didn't realise it was already set for Guix scripts. But yeah, setting it in other places that read derivations makes sense.
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)))