From patchwork Fri Jan 5 19:52:53 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Maxim Cournoyer X-Patchwork-Id: 58393 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 268CE27BBEA; Fri, 5 Jan 2024 19:54:27 +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.7 required=5.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FROM,MAILING_LIST_MULTI, SPF_HELO_PASS autolearn=ham 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 C5B2C27BBE2 for ; Fri, 5 Jan 2024 19:54:22 +0000 (GMT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rLqGY-00010j-Su; Fri, 05 Jan 2024 14:54:02 -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 1rLqGV-0000zg-Og for guix-patches@gnu.org; Fri, 05 Jan 2024 14:53:59 -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 1rLqGV-0007cn-GD for guix-patches@gnu.org; Fri, 05 Jan 2024 14:53:59 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1rLqGZ-0000eL-UP for guix-patches@gnu.org; Fri, 05 Jan 2024 14:54:03 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#68242] [PATCH core-updates v2 4/5] build: gnu-build-system: Compress man pages with zstd. Resent-From: Maxim Cournoyer Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Fri, 05 Jan 2024 19:54:03 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 68242 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 68242@debbugs.gnu.org Cc: Maxim Cournoyer Received: via spool by 68242-submit@debbugs.gnu.org id=B68242.17044844222433 (code B ref 68242); Fri, 05 Jan 2024 19:54:03 +0000 Received: (at 68242) by debbugs.gnu.org; 5 Jan 2024 19:53:42 +0000 Received: from localhost ([127.0.0.1]:57968 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rLqGD-0000d0-7l for submit@debbugs.gnu.org; Fri, 05 Jan 2024 14:53:41 -0500 Received: from mail-qk1-x736.google.com ([2607:f8b0:4864:20::736]:59887) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rLqGA-0000c4-FM for 68242@debbugs.gnu.org; Fri, 05 Jan 2024 14:53:39 -0500 Received: by mail-qk1-x736.google.com with SMTP id af79cd13be357-7815547f2c5so121356085a.3 for <68242@debbugs.gnu.org>; Fri, 05 Jan 2024 11:53:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1704484408; x=1705089208; darn=debbugs.gnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=x+mVD14beS+srRzXQtAc4+5pf7mOTb9TfWsqvebFxF0=; b=Vzy3nzrAxKM0D0sovpmbhDwlDd9pm+cAqvbz/lmR7R/OVTFUaleeK9vDj0+GHsm4wA e60bxMQLMlFK5HUxC9Ym6ekFhEpfvpOjh+C39D7wy+hbDD7gs6phusBd/zQVNFzfhYrf YuJoCHQnQE7YkBS7cv+i5Pq22WuMr6Ue+WiC8iGr/6LoNn6YmdaTh76brXfCrGva4N9Q 6Nj9fRtioxFhfE9C5YLEofnCPDJUrOYrXxcSaw/Xm/gZd3gAB2nf0/szXNKcGcyc1D68 BfOWDPzOSMWB6HqtgEQz6cMgJwJDFMdZNZGBcBWmfUQnwO9S2RmsE234Y6odlgjK1U0o nqyw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704484408; x=1705089208; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=x+mVD14beS+srRzXQtAc4+5pf7mOTb9TfWsqvebFxF0=; b=QjWXQOA6paHJPY2AAJGI3whMTRmZBAWY1lF4za5i5LNIx28RJcZY410md8hqrOXb5s hvDqOk3PmXT+oMuSjVpgTNX2tgPWamB3kuKoCAMDdJUaMdVGu7jgaBfPuAfIdWrZGWU5 86uxfxkG3w/JJOdzG82sbK1xvVI0Z9+y2pGf4xwkSYmyTcmg9CK9NhrNXrUiLi4K0wyO RP2ryWVk0euMpTRlSi7F2moGmcmA1UsPj2nnZ0AByYZgPcOtiEU48qqz3Qomtrv22jre gdHsiOZx93WMHSk8mj3TeJwRkBhe/1MFkT6tjW6xB7XlsAVkKmiPJjNRP/0ZEXhpLcek HEBg== X-Gm-Message-State: AOJu0Yxe+KCYglo/6y64OOCUo43KCfJDS+/RG1YtjCzTnwEMp64gW2gO qNADm1kT+8r+ZUtdOoZG8jGEKycFGGE= X-Google-Smtp-Source: AGHT+IFfQVoYp4D+zc9rd2tXWxb9vfa3iNBCYH7Il+4IE/xlrWDytrwrs/Xe8d22VzKucwUgm6YKYw== X-Received: by 2002:a05:620a:7ef:b0:781:25aa:21fd with SMTP id k15-20020a05620a07ef00b0078125aa21fdmr2220556qkk.72.1704484407970; Fri, 05 Jan 2024 11:53:27 -0800 (PST) Received: from localhost.localdomain (dsl-10-135-125.b2b2c.ca. [72.10.135.125]) by smtp.gmail.com with ESMTPSA id c22-20020a05620a11b600b00781e1c466e7sm823178qkk.24.2024.01.05.11.53.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Jan 2024 11:53:27 -0800 (PST) From: Maxim Cournoyer Date: Fri, 5 Jan 2024 14:52:53 -0500 Message-ID: X-Mailer: git-send-email 2.41.0 In-Reply-To: References: MIME-Version: 1.0 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 The aim is to improve the efficiency of computing the man pages database, which must decompress the man pages. Zstd is faster than gzip, especially for decompression, and has a similar compression ratio. * gnu/packages/commencement.scm (%final-inputs): Add zstd. * guix/build/gnu-build-system.scm (compress-documentation) Update doc. : New arguments. : Rename argument to... : ... this. Add an 'extension' argument to the retarget-symlink nested procedure. Use new arguments in nested 'maybe-compress' procedure. Change-Id: Ibaad4658f8e5151633714d263d9198f56d255020 --- Changes in v2: - Turn string->number into number->string gnu/packages/commencement.scm | 3 +- guix/build/gnu-build-system.scm | 73 +++++++++++++++++++++------------ 2 files changed, 49 insertions(+), 27 deletions(-) diff --git a/gnu/packages/commencement.scm b/gnu/packages/commencement.scm index ae1c91f0d0..51c26339ef 100644 --- a/gnu/packages/commencement.scm +++ b/gnu/packages/commencement.scm @@ -3492,7 +3492,8 @@ (define-public %final-inputs (native-inputs (list (if (target-hurd?) glibc-utf8-locales-final/hurd - glibc-utf8-locales-final))))))) + glibc-utf8-locales-final))))) + ("zstd" ,zstd))) ("sed" ,sed-final) ("grep" ,grep-final) ("xz" ,xz-final) diff --git a/guix/build/gnu-build-system.scm b/guix/build/gnu-build-system.scm index 51b8f9acbf..2f0ffe36fc 100644 --- a/guix/build/gnu-build-system.scm +++ b/guix/build/gnu-build-system.scm @@ -2,7 +2,7 @@ ;;; Copyright © 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020, 2021 Ludovic Courtès ;;; Copyright © 2018 Mark H Weaver ;;; Copyright © 2020 Brendan Tildesley -;;; Copyright © 2021 Maxim Cournoyer +;;; Copyright © 2021, 2022 Maxim Cournoyer ;;; ;;; This file is part of GNU Guix. ;;; @@ -644,21 +644,36 @@ (define* (reset-gzip-timestamps #:key outputs #:allow-other-keys) (((names . directories) ...) (for-each process-directory directories)))) -(define* (compress-documentation #:key outputs +(define* (compress-documentation #:key + outputs (compress-documentation? #t) - (documentation-compressor "gzip") - (documentation-compressor-flags + (info-compressor "gzip") + (info-compressor-flags '("--best" "--no-name")) - (compressed-documentation-extension ".gz") + (info-compressor-file-extension ".gz") + (man-compressor (if (which "zstd") + "zstd" + info-compressor)) + (man-compressor-flags + (if (which "zstd") + (list "-19" "--rm" + "--threads" (number->string + (parallel-job-count))) + info-compressor-flags)) + (man-compressor-file-extension + (if (which "zstd") + ".zst" + info-compressor-file-extension)) #:allow-other-keys) - "When COMPRESS-DOCUMENTATION? is true, compress man pages and Info files -found in OUTPUTS using DOCUMENTATION-COMPRESSOR, called with -DOCUMENTATION-COMPRESSOR-FLAGS." - (define (retarget-symlink link) + "When COMPRESS-INFO-MANUALS? is true, compress Info files found in OUTPUTS +using INFO-COMPRESSOR, called with INFO-COMPRESSOR-FLAGS. Similarly, when +COMPRESS-MAN-PAGES? is true, compress man pages files found in OUTPUTS using +MAN-COMPRESSOR, using MAN-COMPRESSOR-FLAGS." + (define (retarget-symlink link extension) (let ((target (readlink link))) (delete-file link) - (symlink (string-append target compressed-documentation-extension) - (string-append link compressed-documentation-extension)))) + (symlink (string-append target extension) + (string-append link extension)))) (define (has-links? file) ;; Return #t if FILE has hard links. @@ -676,23 +691,23 @@ (define* (compress-documentation #:key outputs (symbolic-link? target-absolute)) (lambda args (if (= ENOENT (system-error-errno args)) - (begin - (format (current-error-port) - "The symbolic link '~a' target is missing: '~a'\n" - symlink target-absolute) - #f) + (format (current-error-port) + "The symbolic link '~a' target is missing: '~a'\n" + symlink target-absolute) (apply throw args)))))) - (define (maybe-compress-directory directory regexp) + (define (maybe-compress-directory directory regexp + compressor + compressor-flags + compressor-extension) (when (directory-exists? directory) (match (find-files directory regexp) - (() ;nothing to compress + (() ;nothing to compress #t) - ((files ...) ;one or more files + ((files ...) ;one or more files (format #t "compressing documentation in '~a' with ~s and flags ~s~%" - directory documentation-compressor - documentation-compressor-flags) + directory compressor compressor-flags) (call-with-values (lambda () (partition symbolic-link? files)) @@ -702,20 +717,26 @@ (define* (compress-documentation #:key outputs ;; unchanged ('gzip' would refuse to compress them anyway.) ;; Also, do not retarget symbolic links pointing to other ;; symbolic links, since these are not compressed. - (for-each retarget-symlink + (for-each (cut retarget-symlink <> compressor-extension) (filter (lambda (symlink) (and (not (points-to-symlink? symlink)) (string-match regexp symlink))) symlinks)) - (apply invoke documentation-compressor - (append documentation-compressor-flags + (apply invoke compressor + (append compressor-flags (remove has-links? regular-files))))))))) (define (maybe-compress output) (maybe-compress-directory (string-append output "/share/man") - "\\.[0-9]+$") + "\\.[0-9]+$" + man-compressor + man-compressor-flags + man-compressor-file-extension) (maybe-compress-directory (string-append output "/share/info") - "\\.info(-[0-9]+)?$")) + "\\.info(-[0-9]+)?$" + info-compressor + info-compressor-flags + info-compressor-file-extension)) (if compress-documentation? (match outputs