From patchwork Mon Jul 5 19:06:32 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: M X-Patchwork-Id: 31182 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 5FA7027BC78; Mon, 5 Jul 2021 20:07:11 +0100 (BST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, FREEMAIL_FROM,MAILING_LIST_MULTI,SPF_HELO_PASS,T_DKIM_INVALID, URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.2 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id A99C127BC81 for ; Mon, 5 Jul 2021 20:07:10 +0100 (BST) Received: from localhost ([::1]:59164 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1m0Tvx-0002lN-MC for patchwork@mira.cbaines.net; Mon, 05 Jul 2021 15:07:09 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:55104) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m0Tvq-0002lF-Co for guix-patches@gnu.org; Mon, 05 Jul 2021 15:07:02 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:35121) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1m0Tvq-0003og-4v for guix-patches@gnu.org; Mon, 05 Jul 2021 15:07:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1m0Tvp-0003bg-VA for guix-patches@gnu.org; Mon, 05 Jul 2021 15:07:01 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#49421] [PATCH] profiles: Optimise 'fonts-dir-file'. Resent-From: Maxime Devos Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Mon, 05 Jul 2021 19:07:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 49421 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 49421@debbugs.gnu.org X-Debbugs-Original-To: guix-patches@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.162551200813844 (code B ref -1); Mon, 05 Jul 2021 19:07:01 +0000 Received: (at submit) by debbugs.gnu.org; 5 Jul 2021 19:06:48 +0000 Received: from localhost ([127.0.0.1]:46667 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1m0Tvc-0003bE-9p for submit@debbugs.gnu.org; Mon, 05 Jul 2021 15:06:48 -0400 Received: from lists.gnu.org ([209.51.188.17]:46666) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1m0Tvb-0003b6-3f for submit@debbugs.gnu.org; Mon, 05 Jul 2021 15:06:47 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54940) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m0Tva-0002jD-Kn for guix-patches@gnu.org; Mon, 05 Jul 2021 15:06:47 -0400 Received: from laurent.telenet-ops.be ([2a02:1800:110:4::f00:19]:37826) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1m0TvX-0003ab-Fq for guix-patches@gnu.org; Mon, 05 Jul 2021 15:06:46 -0400 Received: from butterfly.local ([188.189.37.160]) by laurent.telenet-ops.be with bizsmtp id RX6e2500S3TK16401X6fRe; Mon, 05 Jul 2021 21:06:40 +0200 Message-ID: From: Maxime Devos Date: Mon, 05 Jul 2021 21:06:32 +0200 User-Agent: Evolution 3.34.2 MIME-Version: 1.0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=telenet.be; s=r21; t=1625512000; bh=MKk42yST6cQgFpQLSwQm0V0RnDr8kShPYI9A47IR2dQ=; h=Subject:From:To:Date; b=FOb6COnKsREiTmPN0XeVa8cisyAqlmXdSFgVAeD1VPAdKDUmnm1l6dAkoaZkFo1nd E/M0m+/VNmvly3pejQu4p0Bf/szH4Cv+5bXUpC1ENimyKbSk5tBYtEagJ1QvOWUhx2 ZI8EjRm9FtaJuqmzaVprOb6AFKm/MgG5KXnu1YxNg2hQ5/CXD2h1nCtKDKi8XNXKeB Q5PbW/j0F9Y0uK917p5KrhfmZextk/4xl4o5KXuPBtTGLveK98LTXiUsWBEsU3DPcS 3fhKZ4+NvQJUFtOUCh8CkmkMiBwTtPnnhquEiQN4syq0x8ZweXT0k8IkA5jVbgVoYX 6F5kqJ28q6Gig== Received-SPF: pass client-ip=2a02:1800:110:4::f00:19; envelope-from=maximedevos@telenet.be; helo=laurent.telenet-ops.be X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-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" X-getmail-retrieved-from-mailbox: Patches Hi guix, These two patches should speed up profile generation by optimising the 'fonts-dir-file' hook. The first patch is the most important; from the commit message: ‘Only let the build G-exp refer to inputs that might actually have fonts. That way, if the list of fonts in the manifest didn't change and the new manifest is built, the font files will not be rebuilt.’ The second patch doesn't bring much. To test, you can test whether things like ... $ ./pre-inst-env guix environment --ad-hoc --pure lagrange -- lagrange still work (lagrange is a graphical application using fonts). Not sure what a good ‘benchmark’ would be. Unfortunately, this does not help with the "guix package -i" case, as in that case, the code doesn't have access to all the package objects, and will have to satisfy itself with the store paths, in which case the profile code pessimistically assumes the store item has fonts ... I suppose this restriction could be lifted if/when the gs-fonts package is renamed to font-ghostscript or something like that ... However, the optimisation should work in the "guix environment ... --ad-hoc ...", "guix system reconfigure ..." and (I'd presume) the guix home-manager cases, though I only tested the first. Greetings, Maxime. From a706b8be4f54530b1cd12c03a1bf3941be43be3c Mon Sep 17 00:00:00 2001 From: Maxime Devos Date: Mon, 5 Jul 2021 20:16:22 +0200 Subject: [PATCH 2/2] profiles: Avoid dependency on 'mkfontdir' and friend when unused. Avoid depending on on "mkfontdir" and "mkfontscale" if they won't actually be used, to avoid building the aforementioned packages when they are updated. * guix/profiles.scm (fonts-dir-file)[build]: Note why the '(null? fonts-dir)' check cannot be removed. (fonts-dir-file): When the 'relevant-inputs' list is empty, just build an empty directory. --- guix/profiles.scm | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/guix/profiles.scm b/guix/profiles.scm index 0f9df68f42..6cf480ddf2 100644 --- a/guix/profiles.scm +++ b/guix/profiles.scm @@ -1544,6 +1544,8 @@ files for the fonts of the @var{manifest} entries." "/share/fonts") '#$relevant-inputs)))) (mkdir #$output) + ;; has-fonts? can have false positives, + ;; so this check is necessary. (if (null? fonts-dirs) (exit #t) (let* ((share-dir (string-append #$output "/share")) @@ -1585,15 +1587,20 @@ files for the fonts of the @var{manifest} entries." (delete-file fonts-dir-file)))) directories))))))) - (gexp->derivation "fonts-dir" build - #:modules '((guix build utils) - (guix build union) - (srfi srfi-26)) - #:local-build? #t - #:substitutable? #f - #:properties - `((type . profile-hook) - (hook . fonts-dir)))) + (if (null? relevant-inputs) + ;; Avoid depending on on "mkfontdir" and "mkfontscale" if + ;; they won't actually be used, to avoid building the aforementioned + ;; packages when they are updated. + (lower-object (file-union "fonts-dir" '())) + (gexp->derivation "fonts-dir" build + #:modules '((guix build utils) + (guix build union) + (srfi srfi-26)) + #:local-build? #t + #:substitutable? #f + #:properties + `((type . profile-hook) + (hook . fonts-dir))))) (define (manual-database manifest) "Return a derivation that builds the manual page database (\"mandb\") for -- 2.32.0