From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp2.migadu.com ([2001:41d0:303:e224::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms1.migadu.com with LMTPS id sFJgCyhKHWbWXAEAe85BDQ:P1 (envelope-from ) for ; Mon, 15 Apr 2024 17:39:20 +0200 Received: from aspmx1.migadu.com ([2001:41d0:303:e224::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp2.migadu.com with LMTPS id sFJgCyhKHWbWXAEAe85BDQ (envelope-from ) for ; Mon, 15 Apr 2024 17:39:20 +0200 X-Envelope-To: larch@yhetil.org Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gnu.org header.s=fencepost-gnu-org header.b=a+XL1m1y; spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org"; dmarc=pass (policy=none) header.from=gnu.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1713195560; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding:resent-cc: resent-from:resent-sender:resent-message-id:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=1ICemtEEU1CmhNI7sFvE9ToBYNnUj1tEAAedcWXFjdc=; b=ile4y5l0MxV07BlkDXqmRCZOyjdVYPd9CbY7l6peWUQAQjxXrcGeBkmxe+ZVHCacDDtxIs OPLzOKjFY2gGlyPOep9k8o2aU0EkAlWk27MD6CDcK4ciq2N7xdWuTypv3WJDB/dTUEWHSA D27SW+yBG8pmVPkK8X21oYNmSTo/YWbIThHbQrx/+/n7887ygrT+syvkTtHdVVUrLzlLBW 59w1HrMwGq0B8qaT6qZpxgjIe2EggBkeDzSjC956vN0d902ruSKRcn/JWsFnko9iADJOUX R5tOYtNgPmhjySThdzhqg7uGu+6XtaDVlrAh/SPfCGsWrOY1+ozn8pHzFVgIMw== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1713195560; a=rsa-sha256; cv=none; b=CUFzxGIOsrxEBSTJtXbgg7hKrsVdzdDNiUcy6b/WKOi3nC11PeZmUQK83ZMEnFX4PL1fki u1KILF0Z11GPfu5VZ9SggJaJjJNGsLX29EAA/W12alGv6OPysmfcvNG6igeRsUIu89sU+v lbyWw+09FqSCESFq20t3obbwzYUAFRaoNnLgGEnOLzziX8/OnczdD5nZXK5X1ZnKsywudW /57EuQozu9N5o14bO5irBhj1HPoWMtqoFNO2RGygHLyPenXGa87EaUsBkJdgBmP9wSfWEm O3WlJ4nwez3LuDqhOm8UGK+pnjll4/wymzbsl1JMWCpZjhUDvvUTV0O1wQQmew== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gnu.org header.s=fencepost-gnu-org header.b=a+XL1m1y; spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org"; dmarc=pass (policy=none) header.from=gnu.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id BAEB0103B7 for ; Mon, 15 Apr 2024 17:39:19 +0200 (CEST) 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 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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+larch=yhetil.org@gnu.org Sender: guix-patches-bounces+larch=yhetil.org@gnu.org X-Migadu-Flow: FLOW_IN X-Migadu-Country: US X-Migadu-Spam-Score: -3.07 X-Spam-Score: -3.07 X-Migadu-Queue-Id: BAEB0103B7 X-Migadu-Scanner: mx12.migadu.com X-TUID: 90TJd7eUzOQ4 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 -- 2.41.0