From patchwork Mon Apr 15 15:37:03 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Ludovic_Court=C3=A8s?= X-Patchwork-Id: 63056 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 1BACA27BBEB; Mon, 15 Apr 2024 16:39:23 +0100 (BST) 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_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,SPF_HELO_PASS,URIBL_BLOCKED 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 A33F827BBE9 for ; Mon, 15 Apr 2024 16:39:22 +0100 (BST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rwOQ2-0006Hm-JV; Mon, 15 Apr 2024 11:38:54 -0400 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 1rwOQ0-0006HQ-SE for guix-patches@gnu.org; Mon, 15 Apr 2024 11:38:52 -0400 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 1rwOQ0-0001bP-Jh; Mon, 15 Apr 2024 11:38:52 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1rwOQA-0007zn-Dt; Mon, 15 Apr 2024 11:39:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#70398] [PATCH 1/5] records: Do not inline throws for ABI mismatches. Resent-From: Ludovic =?utf-8?q?Court=C3=A8s?= 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: Mon, 15 Apr 2024 15:39:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 70398 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 70398@debbugs.gnu.org Cc: Ludovic =?utf-8?q?Court=C3=A8s?= , Christopher Baines , Josselin Poiret , Ludovic =?utf-8?q?Court=C3=A8s?= , Mathieu Othacehe , Ricardo Wurmus , Simon Tournier , Tobias Geerinckx-Rice 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 70398-submit@debbugs.gnu.org id=B70398.171319549230315 (code B ref 70398); Mon, 15 Apr 2024 15:39:02 +0000 Received: (at 70398) by debbugs.gnu.org; 15 Apr 2024 15:38:12 +0000 Received: from localhost ([127.0.0.1]:37900 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rwOPI-0007s0-BG for submit@debbugs.gnu.org; Mon, 15 Apr 2024 11:38:11 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60108) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rwOPE-0007pw-TS for 70398@debbugs.gnu.org; Mon, 15 Apr 2024 11:38:06 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rwOOw-0001Tq-MX; Mon, 15 Apr 2024 11:37:47 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-Version:References:In-Reply-To:Date:Subject:To: From; bh=EXkmOYq5C91w+rjqInPiIAPtMC1u/Ul7/eM3xbS+R04=; b=A8fPfDUYuwSzjAJXp8yN mdqlPMtnExmgwydCqqNrIVYH8JXBIzUnIjN69VbT0TcM6dpBQoZx8++b9j5Ny2j065jMbp4QOcchP JzBZBC3f8KuVx9xxg+mcobMSzQ3M+SYjQMx8tuU10tB1k03DSYi1jFeA9vbbGRQeyPmOXEhcniC5J A6DEVT9aOXgJs6koya+jiIXJTENq0r+ZC127FmVE1S/QNxuAPWX0CVAGvPgau6hVm+uff42Jvszc1 wUTjoK/kgwjBNlGuJyVST0e6siw2O7I95evtW5JIgNtf6TdS9wXiYngzAw1747KiFX4cbOenqcORV DFUuBbSwvdsgZA==; From: Ludovic =?utf-8?q?Court=C3=A8s?= Date: Mon, 15 Apr 2024 17:37:03 +0200 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 * guix/records.scm (record-abi-mismatch-error): New procedure. (abi-check): Use it. Change-Id: I49936599716e117b8fbf26fb9d8f462bbbb8e88b --- guix/records.scm | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/guix/records.scm b/guix/records.scm index f4d12a861d..48637ea0a4 100644 --- a/guix/records.scm +++ b/guix/records.scm @@ -1,5 +1,5 @@ ;;; GNU Guix --- Functional package management for GNU -;;; Copyright © 2012-2023 Ludovic Courtès +;;; Copyright © 2012-2024 Ludovic Courtès ;;; Copyright © 2018 Mark H Weaver ;;; ;;; This file is part of GNU Guix. @@ -61,6 +61,11 @@ (define-syntax record-error (string-append "% " (symbol->string type-name) " abi-cookie"))))) + (define (record-abi-mismatch-error type) + (throw 'record-abi-mismatch-error 'abi-check + "~a: record ABI mismatch; recompilation needed" + (list type) '())) + (define (abi-check type cookie) "Return syntax that checks that the current \"application binary interface\" (ABI) for TYPE is equal to COOKIE." @@ -68,9 +73,7 @@ (define-syntax record-error #`(unless (eq? current-abi #,cookie) ;; The source file where this exception is thrown must be ;; recompiled. - (throw 'record-abi-mismatch-error 'abi-check - "~a: record ABI mismatch; recompilation needed" - (list #,type) '())))) + (record-abi-mismatch-error #,type)))) (define* (report-invalid-field-specifier name bindings #:optional parent-form) From patchwork Mon Apr 15 15:37:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Ludovic_Court=C3=A8s?= X-Patchwork-Id: 63054 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 9B48F27BBEB; Mon, 15 Apr 2024 16:39:17 +0100 (BST) 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_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,SPF_HELO_PASS,URIBL_BLOCKED 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 17D9527BBE9 for ; Mon, 15 Apr 2024 16:39:17 +0100 (BST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rwOQ6-0006Jm-8a; Mon, 15 Apr 2024 11:38:58 -0400 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 1rwOQ4-0006J3-P5 for guix-patches@gnu.org; Mon, 15 Apr 2024 11:38:56 -0400 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 1rwOQ4-0001dw-GT; Mon, 15 Apr 2024 11:38:56 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1rwOQE-00081H-Tk; Mon, 15 Apr 2024 11:39:06 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#70398] [PATCH 2/5] packages: Reduce bloat induced by =?utf-8?b?4oCYc2FuaXRpemUtaW5wdXRz4oCZLg==?= Resent-From: Ludovic =?utf-8?q?Court=C3=A8s?= 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: Mon, 15 Apr 2024 15:39:06 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 70398 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 70398@debbugs.gnu.org Cc: Ludovic =?utf-8?q?Court=C3=A8s?= , Christopher Baines , Josselin Poiret , Ludovic =?utf-8?q?Court=C3=A8s?= , Mathieu Othacehe , Ricardo Wurmus , Simon Tournier , Tobias Geerinckx-Rice 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 70398-submit@debbugs.gnu.org id=B70398.171319550530464 (code B ref 70398); Mon, 15 Apr 2024 15:39:06 +0000 Received: (at 70398) by debbugs.gnu.org; 15 Apr 2024 15:38:25 +0000 Received: from localhost ([127.0.0.1]:37906 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rwOPX-0007uo-5S for submit@debbugs.gnu.org; Mon, 15 Apr 2024 11:38:25 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41190) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rwOPG-0007q5-Qe for 70398@debbugs.gnu.org; Mon, 15 Apr 2024 11:38:11 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rwOOx-0001Tr-Mf; Mon, 15 Apr 2024 11:37:47 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-Version:References:In-Reply-To:Date:Subject:To: From; bh=tBUOkiAnBuL2QEmqfFVT8B9c4zk/02jrYmzHc66l0Og=; b=nBKQXczgh9v3c+MQc324 IjkMC80tPsVmIbhMAuoowimD9M4FZv2H2t+RLIdF7pdbeNZnw0N886BW+76c30VnAmhwH+JLyXCBX hS7l62jVFW8POunlSt5qSIOwOxvWrpNeyLrhIix8LFHNwDklAe1OLZYvCnt7Oc4K7ngCXrHcPlEN5 L4hy54zerPC1mw7LXG0NtsyostsGTR0yY0PZdGwKn8SIVTm0saYWAb0XtZZHaFH1mzmS1peNI2TcC 5EF0CZJg4gX/mRVRHT6q1LFs2izhhqfv3Xr/LX9bnjSOiKR26Quh/9vRwRV9Krmd54R20rQXgoqAA zTMkwwGVniYNqg==; From: Ludovic =?utf-8?q?Court=C3=A8s?= Date: Mon, 15 Apr 2024 17:37:04 +0200 Message-ID: <5668e959834c21809c42c1556359eb65bf285caf.1713194148.git.ludo@gnu.org> 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 At -O1, peval does the bulk of the optimization work and it cannot reduce things like (null? (list 1 2)), unlike what happens in CPS at -O2. Thus, reduce the part of ‘sanitize-inputs’ that’s inlined. * guix/packages.scm (maybe-add-input-labels): New procedure. (sanitize-inputs): Turn into a macro; use ‘maybe-add-input-labels’. Change-Id: Id2283bb5a2f5d714722200bdcfe0b0bfa606923f --- guix/packages.scm | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/guix/packages.scm b/guix/packages.scm index 930b1a3b0e..bd6724cdd4 100644 --- a/guix/packages.scm +++ b/guix/packages.scm @@ -1,5 +1,5 @@ ;;; GNU Guix --- Functional package management for GNU -;;; Copyright © 2012-2023 Ludovic Courtès +;;; Copyright © 2012-2024 Ludovic Courtès ;;; Copyright © 2014, 2015, 2017, 2018, 2019 Mark H Weaver ;;; Copyright © 2015 Eric Bavier ;;; Copyright © 2016 Alex Kost @@ -430,15 +430,26 @@ (define %cuirass-supported-systems ;; . (fold delete %supported-systems '("mips64el-linux" "powerpc-linux" "riscv64-linux"))) -(define-inlinable (sanitize-inputs inputs) - "Sanitize INPUTS by turning it into a list of name/package tuples if it's -not already the case." - (cond ((null? inputs) inputs) +(define (maybe-add-input-labels inputs) + "Add labels to INPUTS unless it already has them." + (cond ((null? inputs) + inputs) ((and (pair? (car inputs)) (string? (caar inputs))) inputs) (else (map add-input-label inputs)))) +(define-syntax sanitize-inputs + ;; This is written as a macro rather than as a 'define-inlinable' procedure + ;; because as of Guile 3.0.9, peval can handle (null? '()) but not + ;; (null? (list x y z)); that residual 'null?' test contributes to code + ;; bloat. + (syntax-rules (quote) + "Sanitize INPUTS by turning it into a list of name/package tuples if it's +not already the case." + ((_ '()) '()) + ((_ inputs) (maybe-add-input-labels inputs)))) + (define-syntax current-location-vector (lambda (s) "Like 'current-source-location' but expand to a literal vector with From patchwork Mon Apr 15 15:37:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Ludovic_Court=C3=A8s?= X-Patchwork-Id: 63055 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 77B3027BBEB; Mon, 15 Apr 2024 16:39:20 +0100 (BST) 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_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,SPF_HELO_PASS,URIBL_BLOCKED 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 6432C27BBE9 for ; Mon, 15 Apr 2024 16:39:19 +0100 (BST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rwOQ2-0006I0-SB; Mon, 15 Apr 2024 11:38:54 -0400 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 1rwOQ1-0006HY-Ee for guix-patches@gnu.org; Mon, 15 Apr 2024 11:38:53 -0400 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 1rwOQ1-0001bY-5v; Mon, 15 Apr 2024 11:38:53 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1rwOQB-000805-8b; Mon, 15 Apr 2024 11:39:03 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#70398] [PATCH 3/5] records: Do not inline the constructor. Resent-From: Ludovic =?utf-8?q?Court=C3=A8s?= 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: Mon, 15 Apr 2024 15:39:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 70398 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 70398@debbugs.gnu.org Cc: Ludovic =?utf-8?q?Court=C3=A8s?= , Christopher Baines , Josselin Poiret , Ludovic =?utf-8?q?Court=C3=A8s?= , Mathieu Othacehe , Ricardo Wurmus , Simon Tournier , Tobias Geerinckx-Rice 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 70398-submit@debbugs.gnu.org id=B70398.171319550130407 (code B ref 70398); Mon, 15 Apr 2024 15:39:02 +0000 Received: (at 70398) by debbugs.gnu.org; 15 Apr 2024 15:38:21 +0000 Received: from localhost ([127.0.0.1]:37902 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rwOPU-0007uG-4I for submit@debbugs.gnu.org; Mon, 15 Apr 2024 11:38:21 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60120) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rwOPG-0007q0-HP for 70398@debbugs.gnu.org; Mon, 15 Apr 2024 11:38:07 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rwOOy-0001UD-Fs; Mon, 15 Apr 2024 11:37:48 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-Version:References:In-Reply-To:Date:Subject:To: From; bh=1ICemtEEU1CmhNI7sFvE9ToBYNnUj1tEAAedcWXFjdc=; b=a+XL1m1yYrn9FByrq3AK ExBKiCq26aGxG9x/uxLvEA8Zy0/IIE/yWjt5NI+Q9TUix6yXVKvtjqpcQzBlkNh/t1UPkvAkabdLt YbnWn9EbsyzoyMmY28zQwI6GitrKoXTTyK173Se8YR4W47wDU8jpm5MDhz2YSxr/XOwBIHvTWem1r DY2vI8jRqXSSptky1jf9ob335zNy11Y0TAL1uLoVzbC8uhp63r8hfq+WDQC+IMoTYqDgW5OcnEn31 U/daNdBICHrViFAN1WLMGGfA/gLeGhTXWyjbQFQlv2DZt4kbEc9Ttv3UP/t1+W4iwKZOG9aygnNqo fbqwh+QfZ4Ej7Q==; From: Ludovic =?utf-8?q?Court=C3=A8s?= Date: Mon, 15 Apr 2024 17:37:05 +0200 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 Struct initialization uses one instruction per field, which contributes to code bloat in the case of package modules. With this change, the ‘.rtl-text’ section of ‘gnu/packages/tex.go’ goes from 7,334,508 B to 6,356,592 B (-13%; -7% on the whole file size), which alone is still larger than the source file (4,2 MB). * guix/records.scm (make-syntactic-constructor)[record-inheritance]: Use CTOR instead of ‘make-struct/no-tail’. Pass ABI-COOKIE as the first argument to CTOR. (define-record-type*): Define CTOR-PROCEDURE and pass it to ‘make-syntactic-constructor’. Change-Id: Ifd7b4e884e9fbf21c43fb4c3ad963126ef5cb476 --- guix/records.scm | 47 +++++++++++++++++++++++++++++++++-------------- 1 file changed, 33 insertions(+), 14 deletions(-) diff --git a/guix/records.scm b/guix/records.scm index 48637ea0a4..dca1e3c2e7 100644 --- a/guix/records.scm +++ b/guix/records.scm @@ -164,16 +164,16 @@ (define-syntax make-syntactic-constructor (record-error 'name s "extraneous field initializers ~a" unexpected))) - #`(make-struct/no-tail type - #,@(map (lambda (field index) - (or (field-inherited-value field) - (if (innate-field? field) - (wrap-field-value - field (field-default-value field)) - #`(struct-ref #,orig-record - #,index)))) - '(expected ...) - (iota (length '(expected ...)))))) + #`(ctor #,abi-cookie + #,@(map (lambda (field index) + (or (field-inherited-value field) + (if (innate-field? field) + (wrap-field-value + field (field-default-value field)) + #`(struct-ref #,orig-record + #,index)))) + '(expected ...) + (iota (length '(expected ...)))))) (define (thunked-field? f) (memq (syntax->datum f) 'thunked)) @@ -249,8 +249,8 @@ (define-syntax make-syntactic-constructor (cond ((lset= eq? fields '(expected ...)) #`(let* #,(field-bindings #'((field value) (... ...))) - #,(abi-check #'type abi-cookie) - (ctor #,@(map field-value '(expected ...))))) + (ctor #,abi-cookie + #,@(map field-value '(expected ...))))) ((pair? (lset-difference eq? fields '(expected ...))) (record-error 'name s @@ -435,7 +435,13 @@ (define-syntax define-record-type* (sanitizers (filter-map field-sanitizer #'((field properties ...) ...))) (cookie (compute-abi-cookie field-spec))) - (with-syntax (((field-spec* ...) + (with-syntax ((ctor-procedure + (datum->syntax + #'ctor + (symbol-append (string->symbol " %") + (syntax->datum #'ctor) + '-procedure/abi-check))) + ((field-spec* ...) (map field-spec->srfi-9 field-spec)) ((field-type ...) (map (match-lambda @@ -502,7 +508,20 @@ (define-syntax define-record-type* #'id))))))) thunked-field-accessor ... delayed-field-accessor ... - (make-syntactic-constructor type syntactic-ctor ctor + + (define ctor-procedure + ;; This procedure is *not* inlined, to reduce code bloat + ;; (struct initialization takes at least one instruction per + ;; field). + (case-lambda + ((cookie field ...) + (unless (eq? cookie #,cookie) + (record-abi-mismatch-error type)) + (ctor field ...)) + (_ + (record-abi-mismatch-error type)))) + + (make-syntactic-constructor type syntactic-ctor ctor-procedure (field ...) #:abi-cookie #,cookie #:thunked #,thunked From patchwork Mon Apr 15 15:37:06 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Ludovic_Court=C3=A8s?= X-Patchwork-Id: 63058 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 BE54727BBEB; Mon, 15 Apr 2024 16:39:38 +0100 (BST) 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_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,SPF_HELO_PASS,URIBL_BLOCKED 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 4AC1727BBE9 for ; Mon, 15 Apr 2024 16:39:38 +0100 (BST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rwOQ4-0006J6-Ts; Mon, 15 Apr 2024 11:38:56 -0400 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 1rwOQ4-0006IZ-8l for guix-patches@gnu.org; Mon, 15 Apr 2024 11:38:56 -0400 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 1rwOQ3-0001da-W7; Mon, 15 Apr 2024 11:38:56 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1rwOQC-00080X-Ts; Mon, 15 Apr 2024 11:39:04 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#70398] [PATCH 4/5] packages: =?utf-8?b?4oCYZGVmaW5lLXB1Ymxp?= =?utf-8?b?Y+KAmQ==?= replacement calls =?utf-8?b?4oCYbW9kdWxlLWV4cG9ydCE=?= =?utf-8?b?4oCZ?= directly. Resent-From: Ludovic =?utf-8?q?Court=C3=A8s?= 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: Mon, 15 Apr 2024 15:39:04 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 70398 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 70398@debbugs.gnu.org Cc: Ludovic =?utf-8?q?Court=C3=A8s?= , Christopher Baines , Josselin Poiret , Ludovic =?utf-8?q?Court=C3=A8s?= , Mathieu Othacehe , Ricardo Wurmus , Simon Tournier , Tobias Geerinckx-Rice 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 70398-submit@debbugs.gnu.org id=B70398.171319550330438 (code B ref 70398); Mon, 15 Apr 2024 15:39:04 +0000 Received: (at 70398) by debbugs.gnu.org; 15 Apr 2024 15:38:23 +0000 Received: from localhost ([127.0.0.1]:37904 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rwOPV-0007uO-Jq for submit@debbugs.gnu.org; Mon, 15 Apr 2024 11:38:23 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41180) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rwOPG-0007q2-NG for 70398@debbugs.gnu.org; Mon, 15 Apr 2024 11:38:08 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rwOOz-0001UY-K6; Mon, 15 Apr 2024 11:37:49 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-Version:References:In-Reply-To:Date:Subject:To: From; bh=Lzhqu2e+cAy1Td6udzgnsfK/iejWG8dEsKU670jPODA=; b=NsruURYwoStjrRLCluVZ MIxXquM/bL6MgDIRt+4s32RyGpCghD4xXDbetl/XkmjKMrmsCxShIgVB+mEYGiYEv4SHvRKC0E0m7 4yUr2LqKMNGcA0usT0/bRE3/l1aP/eurDYRLZuhbS92jCmXLef9a+ZebN85qWUcV77XnkOoKNhAqm jKYxpJQWbWHtXfOSaXU+hpdQN2aWyNstvmFRL/EGpHAFE33bo1Pn2eCS4So5tZ+RxsIGKy+Fm8nHc DBGKeo2CBU4wfMUeQ/20+i8x3j8i2/Z8yXeMusy8abmdJJ8rOcbwp3cEipCU7mVXXhjIodVNx2gqp pWhs63OL/RgStw==; From: Ludovic =?utf-8?q?Court=C3=A8s?= Date: Mon, 15 Apr 2024 17:37:06 +0200 Message-ID: <723be7e4e70628f32862b8c1043eee641c4ccf8c.1713194148.git.ludo@gnu.org> 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 This reduces code bloat and loading overhead for package modules, which use ‘define-public’ extensively. * guix/packages.scm (define-public*): Use ‘define’ followed by ‘module-export!’ directly instead of ‘define-public’. Change-Id: I7f56d46b391c1e3eeeb0b9a08a9d34b5de341245 --- guix/packages.scm | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/guix/packages.scm b/guix/packages.scm index bd6724cdd4..6c697bcc67 100644 --- a/guix/packages.scm +++ b/guix/packages.scm @@ -482,7 +482,8 @@ (define-syntax-parameter current-definition-location (define-syntax define-public* (lambda (s) "Like 'define-public' but set 'current-definition-location' for the -lexical scope of its body." +lexical scope of its body. (This also disables notification of \"module +observers\", but this is unlikely to affect anyone.)" (define location (match (syntax-source s) (#f #f) @@ -499,10 +500,21 @@ (define-syntax define-public* (syntax-case s () ((_ prototype body ...) - #`(define-public prototype - (syntax-parameterize ((current-definition-location - (lambda (s) #,location))) - body ...)))))) + (with-syntax ((name (syntax-case #'prototype () + ((id _ ...) #'id) + (id #'id)))) + #`(begin + (define prototype + (syntax-parameterize ((current-definition-location + (lambda (s) #,location))) + body ...)) + + ;; Note: Use 'module-export!' directly to avoid emitting a + ;; 'call-with-deferred-observers' call for each 'define-public*' + ;; instance, which is not only pointless but also contributes to + ;; code bloat and to load-time overhead in package modules. + (eval-when (expand load eval) + (module-export! (current-module) '(name))))))))) (define-syntax validate-texinfo (let ((validate? (getenv "GUIX_UNINSTALLED"))) From patchwork Mon Apr 15 15:37:07 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Ludovic_Court=C3=A8s?= X-Patchwork-Id: 63057 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 2D76B27BBEA; Mon, 15 Apr 2024 16:39:28 +0100 (BST) 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_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,SPF_HELO_PASS,URIBL_BLOCKED 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 4657227BBE9 for ; Mon, 15 Apr 2024 16:39:26 +0100 (BST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rwOQ8-0006KY-GX; Mon, 15 Apr 2024 11:39:00 -0400 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 1rwOQ6-0006Jh-2U for guix-patches@gnu.org; Mon, 15 Apr 2024 11:38:58 -0400 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 1rwOQ5-0001en-Ps; Mon, 15 Apr 2024 11:38:57 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1rwOQF-00081Q-9K; Mon, 15 Apr 2024 11:39:07 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#70398] [PATCH 5/5] packages: Reduce code bloat due to list allocation in input fields. Resent-From: Ludovic =?utf-8?q?Court=C3=A8s?= 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: Mon, 15 Apr 2024 15:39:07 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 70398 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 70398@debbugs.gnu.org Cc: Ludovic =?utf-8?q?Court=C3=A8s?= , Christopher Baines , Josselin Poiret , Ludovic =?utf-8?q?Court=C3=A8s?= , Mathieu Othacehe , Ricardo Wurmus , Simon Tournier , Tobias Geerinckx-Rice 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 70398-submit@debbugs.gnu.org id=B70398.171319550830489 (code B ref 70398); Mon, 15 Apr 2024 15:39:07 +0000 Received: (at 70398) by debbugs.gnu.org; 15 Apr 2024 15:38:28 +0000 Received: from localhost ([127.0.0.1]:37908 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rwOPZ-0007vF-8Z for submit@debbugs.gnu.org; Mon, 15 Apr 2024 11:38:27 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41200) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rwOPH-0007qJ-GZ for 70398@debbugs.gnu.org; Mon, 15 Apr 2024 11:38:11 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rwOP0-0001Uv-F0; Mon, 15 Apr 2024 11:37:50 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-Version:References:In-Reply-To:Date:Subject:To: From; bh=5vXsn8BSLiVvAWZCYbh1dNBBvzLJn4lDK2zl8EwU1cw=; b=Y0I7T/nN6wfQPUlEGQ0C +40E6lYiOFeR7ItfcJkyd0c6q7xnvj70+3j1J4geC5Kpp4D8xFVqFstFjamN7nvhRI5ADVVIGUccV XKJhrTtdhds1Sl5uCZqt+xC4UDE8C7TAKn24r1/ltWU2vldiv1WisnU8QuqFFnpscz4EJ7WB8iJ5e eZkzAyKeUEIPq3BOLopT99TOiPS6nq2czeif8ajMsmfE9KK6oEIKHMr+cipvbN7pm7FwKAuOHqUTj Li2cx+tVduWn8Iu3KlU1kq6BihadjnEKE8FMRvtC3hZToKlWiRMTb07JPdQnk8YDIfI8tnt2xy2EE 3LLKdRQnXXEv6w==; From: Ludovic =?utf-8?q?Court=C3=A8s?= Date: Mon, 15 Apr 2024 17:37:07 +0200 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 * guix/packages.scm (add-input-labels): New procedure. (sanitize-inputs): Add case for (list …). Change-Id: Ice8241508ded51efd38867b97ca19c262b8c4363 --- guix/packages.scm | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/guix/packages.scm b/guix/packages.scm index 6c697bcc67..3a4f547d6b 100644 --- a/guix/packages.scm +++ b/guix/packages.scm @@ -439,16 +439,26 @@ (define (maybe-add-input-labels inputs) inputs) (else (map add-input-label inputs)))) +(define (add-input-labels . inputs) + "Add labels to all of INPUTS." + (map add-input-label inputs)) + (define-syntax sanitize-inputs ;; This is written as a macro rather than as a 'define-inlinable' procedure ;; because as of Guile 3.0.9, peval can handle (null? '()) but not ;; (null? (list x y z)); that residual 'null?' test contributes to code ;; bloat. - (syntax-rules (quote) + (syntax-rules (quote list) "Sanitize INPUTS by turning it into a list of name/package tuples if it's not already the case." ((_ '()) '()) - ((_ inputs) (maybe-add-input-labels inputs)))) + ((_ (list args ...)) + ;; As of 3.0.9, (list ...) is open-coded, which can lead to a long list + ;; of instructions. To reduce code bloat in package modules where input + ;; fields may create such lists, move list allocation to the callee. + (add-input-labels args ...)) + ((_ inputs) + (maybe-add-input-labels inputs)))) (define-syntax current-location-vector (lambda (s)