From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp1.migadu.com ([2001:41d0:403:4876::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms13.migadu.com with LMTPS id WNRhA2Yvb2dM3wAA62LTzQ:P1 (envelope-from ) for ; Fri, 27 Dec 2024 22:51:18 +0000 Received: from aspmx1.migadu.com ([2001:41d0:403:4876::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp1.migadu.com with LMTPS id WNRhA2Yvb2dM3wAA62LTzQ (envelope-from ) for ; Fri, 27 Dec 2024 23:51:18 +0100 X-Envelope-To: larch@yhetil.org Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=debbugs.gnu.org header.s=debbugs-gnu-org header.b=FMBCVqfH; dkim=fail ("headers rsa verify failed") header.d=wolfsden.cz header.s=mail header.b=uzLyvFdU; dkim=fail ("headers rsa verify failed") header.d=wolfsden.cz header.s=mail header.b=Sz11eS+x; spf=pass (aspmx1.migadu.com: domain of "bug-guix-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="bug-guix-bounces+larch=yhetil.org@gnu.org"; dmarc=fail reason="SPF not aligned (relaxed), DKIM not aligned (relaxed)" header.from=wolfsden.cz (policy=none) ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1735339878; 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: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=tkPjPFeY5hACCvPAA5NHtJQM56SH7A6vIGZGnUyMlX0=; b=u/soTw4nHqbp1TJzI7cMWc5puvmWtg4EpIsmWrRTIGTyY61ICf//OeZpbJ0MQtKIWvdcGq UewyqqFhp2EsAaqlsECpvD+axblCH2FAfQXIeu6EDBRDBhrNT82EwoU2678oq9+7rgIW/u fKheP+NSFvk/ZjJQrs3OSaiV+7OokJnntHZLVPXsAOPcmKXnJ6vfRwvMmWK8uyg2A4ZfO1 nAOhFpa2VzkpFe1DNFnJZhPYY4aKMuIItQu655Dvji3zcpBPju+myORY4Q/TA9rGN/gpPV x1whW8spL7vjMZK4hc+PWYoKWTzcX0xV4qET9+xefgZZQw+kCpPXSlU61mwuXw== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=debbugs.gnu.org header.s=debbugs-gnu-org header.b=FMBCVqfH; dkim=fail ("headers rsa verify failed") header.d=wolfsden.cz header.s=mail header.b=uzLyvFdU; dkim=fail ("headers rsa verify failed") header.d=wolfsden.cz header.s=mail header.b=Sz11eS+x; spf=pass (aspmx1.migadu.com: domain of "bug-guix-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="bug-guix-bounces+larch=yhetil.org@gnu.org"; dmarc=fail reason="SPF not aligned (relaxed), DKIM not aligned (relaxed)" header.from=wolfsden.cz (policy=none) ARC-Seal: i=1; s=key1; d=yhetil.org; t=1735339878; a=rsa-sha256; cv=none; b=AxRdxnDKU/DQVagNT6yDqTeYOjMdFavZrdJTkeKtIihsvksqI+Ppt/epL+G/OIy382efKW FjactwytjGK5RBarHvs3fKP5/FLPFQgUZ50yBxbb9yB9QHuc4YQE/KoH7mE9Hs/p/EqTwx PMjOFUdxW6ID2fph5UYxl3V5KGUyuBHfRrxOKbUTT3W2iOg/TVeBbMROsANNfSfB6bZNsZ a3vxXFGdgALMWU7XvhZO0mjShQYVblMlsohjdQGHwkpvABANBgsc1vVL/6Z+DRqlFrIhqA kKSVDM33BQpsuC7uiEr/rdmwBGDfgUMMAUsR4o17DEIdNPGoCFbyG0vtxCb2Jg== 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 531E796D87 for ; Fri, 27 Dec 2024 23:51:16 +0100 (CET) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tRJAh-0003KP-2j; Fri, 27 Dec 2024 17:51:07 -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 1tRJAc-0003K9-BA for bug-guix@gnu.org; Fri, 27 Dec 2024 17:51:03 -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 1tRJAc-0007qR-2X for bug-guix@gnu.org; Fri, 27 Dec 2024 17:51:02 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debbugs.gnu.org; s=debbugs-gnu-org; h=MIME-Version:Date:References:In-Reply-To:From:To:Subject; bh=tkPjPFeY5hACCvPAA5NHtJQM56SH7A6vIGZGnUyMlX0=; b=FMBCVqfHTrw7NFNkoKCRMt1gnkYiyhl9h7BAyGPJiWM+BDVpUNvm7zbZ3QTAzlC6TAj13Jvt1krnOpl79ngtxcBYlXEYwCKcnx+ZLgKq+G4sILjx+1Lrxk+OybfDlqv7Gr2aPZlzfnEffeS2ouJ+5sTQsKnnJgyJFVLiOuR6j7xUlVa61OFwe65saDEyteQbFoeutg4NydCoPxJsrb8fTV5mlJi3SmhZ1DPeEgcOkpYwyO+m4/1syR/k73agOTJTQ31mPgts/48JSyUsMNRJXP9vpZKkvSYFdzEsS+dCrMo41Y8GBoAjYGrMo8E4QIdKuPUjHXZfhJtnLwpu6HB1nA==; Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1tRJAb-0004lt-NU for bug-guix@gnu.org; Fri, 27 Dec 2024 17:51:01 -0500 X-Loop: help-debbugs@gnu.org Subject: bug#74748: Constructor created by define-configuration is slow (>25s) when many fields are defined Resent-From: Tomas Volf <~@wolfsden.cz> Original-Sender: "Debbugs-submit" Resent-CC: bug-guix@gnu.org Resent-Date: Fri, 27 Dec 2024 22:51:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 74748 X-GNU-PR-Package: guix X-GNU-PR-Keywords: To: Ludovic =?UTF-8?Q?Court=C3=A8s?= Cc: 74748@debbugs.gnu.org Received: via spool by 74748-submit@debbugs.gnu.org id=B74748.173533981318272 (code B ref 74748); Fri, 27 Dec 2024 22:51:01 +0000 Received: (at 74748) by debbugs.gnu.org; 27 Dec 2024 22:50:13 +0000 Received: from localhost ([127.0.0.1]:47925 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tRJ9p-0004kd-5I for submit@debbugs.gnu.org; Fri, 27 Dec 2024 17:50:13 -0500 Received: from wolfsden.cz ([37.205.8.62]:43434) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from <~@wolfsden.cz>) id 1tRJ9m-0004im-K1 for 74748@debbugs.gnu.org; Fri, 27 Dec 2024 17:50:12 -0500 Received: by wolfsden.cz (Postfix, from userid 104) id 4E920338C03; Fri, 27 Dec 2024 22:50:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=wolfsden.cz; s=mail; t=1735339808; bh=hRkZ0BGGlJhR2bJ/YU1HOiEKlKREB3LnibkG3rX6Y1w=; h=From:To:Cc:Subject:In-Reply-To:References:Date; b=uzLyvFdU3Q94oSj+Ogl9li/f5hfLVeENUYONidRT6ptjqzZJ1zVTjZisQxa5V18B1 s+r0I+aI1bbLQeR5IYjmxnlhSn+hJpcKV8obwSmQlTbd/sqweQ2HvUOFolgVZ7ZC9e yonSHMa/a7KbphxnZJ/RPMBkd39py1vMQ+/m++amlsF29ss43KzDS5E79jlphJA+if CKnmTtDl72w0cIO7NjimmwTbxZepVvyOyjUtr8p6d5BzEzJkuHM7SSEo80wEEEGT+k oCtR0PRa0eJcz3r8/O2b7lNRYHCdfdVU8Gp7c8oIBn4qUvATjSYelP/34t3CTE+Tty Mjep4TDSTz74gG5jfUtBqmbFqn/9ZspBjtUTVtH3FqFJswqXedso9ELGl7EyPtEVOE q20TkH2plpHpu24lU7bhN8bERP7IedrofeHDW8hYQsCsVvQ5uP9GW7kSTszMZUWyBv ap1pee1yRxzRcmIcCBP7eGkTiV/BlLUmtD+w0i35HG8pV7O2IOtZaAFJpOY/zfWRiB gUJ1KGxCvtNLuu3wrhYv6HM6qvxw+SXdq62G9G77rsRRfNO5U4O5bMbIuqSq+af1Ky 0TLdveQ87jnPfkz1Q1nkVaygAoZ8lwEen14qok5JOyx2Cf+S3HrfUouBoRiJBEaGpC 1UvKcynC3jlet1xUyCgMWAJg= Received: from localhost (unknown [128.0.188.242]) by wolfsden.cz (Postfix) with ESMTPSA id 73B4733883B; Fri, 27 Dec 2024 22:50:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=wolfsden.cz; s=mail; t=1735339807; bh=hRkZ0BGGlJhR2bJ/YU1HOiEKlKREB3LnibkG3rX6Y1w=; h=From:To:Cc:Subject:In-Reply-To:References:Date; b=Sz11eS+xLWZKO0xXzCX2/Nc2CCU2jYKVGalMCyzmLe/VDXLsg+xjwk7l9kVG5lFSN 6APM57kKks87jq7CwlBvu4f1PXwKWcLw4A9TJetQZCUU2h4RTaYSkmpnyvNXh9T1qJ BQ1RpwZBrusmg48kh3PBmdy8lfb/Ul9WLEGnk4K2lry4UCE/TIZW7284Exp89WZbXM 3UwGJVXXmJenRLi+YCln0ZyAC8fHgEGHiV5fZf4fVmYjZOKNVfkhIE0ku3y0HxXjJN aepLQGHoG7uif4njBgVYy0J5x82DnyWgV98aH8NKRUbi9uTbnY4GbOQa/P5t9vJZCZ e3eJ2BaFG9k90VfA97HzDzr4dRbUw6thldt7flVe6Bl2Y5in5f8DF3o7eoUWKUaXrn 40A+8mAkq62ysafYXWQe0Ku3KQ1l9A1tgjIo1z842RKe69gq02lxM81uZYq0T3zgqC Qk3Dm3hMY5/mjW9sp0dBqDNPvit46i5xslrUVl1M2XHIR19fVjRE/AhuHpBs44WAmm +wfDF+j5iHadApNhymyHj1kLfhMTgVQQQ1d0oRAWDQZnm9cA8i9UVEnJXHp7HBD5xx 6xafFiQcjaO1lHBJfpguSPBNlIVs14GcWIUwuxISJ4TF6On5pQZdSk+P3pOc4DMQ6B DEW86FRxBwjlVHeYyMQ4EKLs= From: Tomas Volf <~@wolfsden.cz> In-Reply-To: <87cyhh5eop.fsf@gnu.org> ("Ludovic =?UTF-8?Q?Court=C3=A8s?="'s message of "Tue, 24 Dec 2024 15:38:30 +0100") References: <87msh499f7.fsf@wolfsden.cz> <87cyhh5eop.fsf@gnu.org> Date: Fri, 27 Dec 2024 23:50:06 +0100 Message-ID: <87a5cg4u75.fsf@wolfsden.cz> User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha512; protocol="application/pgp-signature" X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-guix@gnu.org List-Id: Bug reports for GNU Guix List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-guix-bounces+larch=yhetil.org@gnu.org Sender: bug-guix-bounces+larch=yhetil.org@gnu.org X-Migadu-Country: US X-Migadu-Flow: FLOW_IN X-Migadu-Spam-Score: -6.76 X-Spam-Score: -6.76 X-Migadu-Queue-Id: 531E796D87 X-Migadu-Scanner: mx10.migadu.com X-TUID: fucK15Zair8m --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Hello, thank you for finding the time to look into this issue. Replies below. Ludovic Court=C3=A8s writes: > Hi, > > Tomas Volf <~@wolfsden.cz> skribis: > >> I am writing a configuration for mpv and hit an issue of the generated >> constructor (`home-mpv-configuration') is extremely slow. While the >> almost 800 fields is unusually high, initializing the instances of the >> record should *not* take almost 30 seconds. The full file is attached >> to this email (as `mpv.scm'). > > AFAICS, time is spent in one of the compilation steps: > > scheme@(gnu home services mpv)> ,o interp #t > scheme@(gnu home services mpv)> ,t (lambda () (mpv-profile-configuration)) > $13 =3D # > ;; 0.376347s real time, 0.375402s run time. 0.000000s spent in GC. > scheme@(gnu home services mpv)> ,o interp #f > scheme@(gnu home services mpv)> ,t (lambda () (mpv-profile-configuration)) > $14 =3D #:40:3 ()> > ;; 11.149828s real time, 12.052915s run time. 1.581736s spent in GC. > scheme@(gnu home services mpv)> ,t (->bool (macroexpand '(mpv-profile-con= figuration))) > $15 =3D #t > ;; 0.373865s real time, 0.372698s run time. 0.000000s spent in GC. > > > If we look more closely, it=E2=80=99s the optimizing compiler that takes = time; > the baseline compile (-O1) is doing okay: > > scheme@(gnu home services mpv)> ,use(system base compile) > scheme@(gnu home services mpv)> ,t (->bool (compile '(mpv-profile-configu= ration) #:to 'tree-il #:env (current-module))) > $20 =3D #t > ;; 0.378741s real time, 0.377043s run time. 0.000000s spent in GC. > scheme@(gnu home services mpv)> ,t (->bool (compile '(mpv-profile-configu= ration) #:to 'bytecode #:env (current-module))) > $21 =3D #t > ;; 11.946879s real time, 12.961704s run time. 1.777478s spent in GC. > scheme@(gnu home services mpv)> (define til (compile '(mpv-profile-config= uration) #:to 'tree-il #:env (current-module))) > scheme@(gnu home services mpv)> ,t (->bool (compile til #:from 'tree-il #= :to 'bytecode)) > $22 =3D #t > ;; 11.403420s real time, 12.317183s run time. 1.581972s spent in GC. > scheme@(gnu home services mpv)> ,t (->bool (compile til #:from 'tree-il #= :to 'bytecode #:optimization-level 1)) > $23 =3D #t > ;; 0.225455s real time, 0.156137s run time. 0.000000s spent in GC. > > Currently (guix build compile) applies these options to services: > > ((string-contains file "gnu/services/") > ;; '-O2 -Ono-letrectify' compiles about ~20% faster than '-O2' f= or > ;; large files like gnu/services/mail.scm. > (override-option #:letrectify? #f > (optimizations-for-level 2))) > > I think we should at least apply this patch: > > diff --git a/guix/build/compile.scm b/guix/build/compile.scm > index 5b27b55d02..f90016b9ae 100644 > --- a/guix/build/compile.scm > +++ b/guix/build/compile.scm > @@ -127,7 +127,8 @@ (define (optimization-options file) > ;; Use '-O1' to have partial evaluation and primitive inlining = so we > ;; can honor the "macro writer's bill of rights". > (optimizations-for-level 1)) > - ((string-contains file "gnu/services/") > + ((or (string-contains file "gnu/services/") > + (string-contains file "gnu/home/services/")) > ;; '-O2 -Ono-letrectify' compiles about ~20% faster than '-O2' = for > ;; large files like gnu/services/mail.scm. > (override-option #:letrectify? #f > > > Would that be enough for the home-mpv configuration records you wrote? I admit I did not test the patch attached, but my understanding is that even if the speed up was sufficient, it would take effect only for compilation via the make command. Assuming that is correct, it would not change much. I am (luckily) former C++ developer, so I am used to compilations taking ~forever. So, yes, while the compilation of mpv.scm (via `make') took roughly 40s on my machine, it was annoying, but not worthy of a bug report. The actual problem for me was the slowness in REPL. Would that be addressed by the patch above? If not, do we have any way to do that? )tomas =2D-=20 There are only two hard things in Computer Science: cache invalidation, naming things and off-by-one errors. --=-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQJCBAEBCgAsFiEEt4NJs4wUfTYpiGikL7/ufbZ/wakFAmdvLx4OHH5Ad29sZnNk ZW4uY3oACgkQL7/ufbZ/wanyqQ/+IWaH5/3zSHoUTrz+j5Wj6IOPD6MX23oqzmrh NJ5SpG4N6zl7oOI5UBOaYE/FQgBqvlgFcjHSrU+j/3k7GCx/1PY/Uuck72zFuDR7 Lx32SCOC2Rg5XoIhkhTm7iAiH7JXkRjD/jaQWvOBmxtc0i/jGsHycKrsKnfwBzdM YzqFh9y4gNJw7KC2TFIubkRAW/9hdXMS3vjVcsxd8DUn2OW23jJA70Jf1vGA8njo R3QA+PVFz280Ng/TTxt7gz8gxSP11J/CN2f1gDGAk48Wpi7+SjOv575I+P+f3mAj HriqaCFGHdN/K5elvLBNWzFoN0V2VJ47CYOStlFDkPxiSw7J5TWKpPWA9vtF2XmZ sobYVSW/59yihcvsNqkStj36IWveWDEccLG0B/uisjzgvh6V/TPu0ddbOE0ncbif YtUSf2Cb2aKQq+xU5AomzLqsjs2DCJ46qB2e9u53iL5AzhxJjFsurWyUThF0cmT1 oQScABso3HKf3YSYinNby+aKRbNhVcB6FkEMHtmpU5WDiYt3wyhMnau8Xj0M94Me fZJcHadDwn6bELxp3p4O5r2fsV+vtiP8Stpr4WB1ZPCmoHQglMa5R8DbzL25pQvI rcgZB/A2N6oeLVfHZHqCRxIRuR9oCj3JYs5At8fmg+G1YFr0VAh+P8xi+qQl+q8Y fuXkkdI= =PAc9 -----END PGP SIGNATURE----- --=-=-=--