From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp1 ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms11 with LMTPS id L5q5A9Wn2F6gRQAA0tVLHw (envelope-from ) for ; Thu, 04 Jun 2020 07:50:45 +0000 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp1 with LMTPS id 2GsSO9Sn2F7geQAAbx9fmQ (envelope-from ) for ; Thu, 04 Jun 2020 07:50:44 +0000 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 71D1B9404E2 for ; Thu, 4 Jun 2020 07:50:44 +0000 (UTC) Received: from localhost ([::1]:36992 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jgkeB-00066N-An for larch@yhetil.org; Thu, 04 Jun 2020 03:50:43 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46138) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jgkdp-00063R-Kv for guix-devel@gnu.org; Thu, 04 Jun 2020 03:50:21 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]:56318) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jgkdn-0006AS-MY; Thu, 04 Jun 2020 03:50:19 -0400 Received: from [2a01:e0a:1d:7270:af76:b9b:ca24:c465] (port=43760 helo=ribbon) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1jgkdn-0005OK-A4; Thu, 04 Jun 2020 03:50:19 -0400 From: =?utf-8?Q?Ludovic_Court=C3=A8s?= To: guix-devel@gnu.org, Andy Wingo Subject: Compilation time with Guile 3.0.3-to-be X-URL: http://www.fdn.fr/~lcourtes/ X-Revolutionary-Date: 17 Prairial an 228 de la =?utf-8?Q?R=C3=A9volution?= X-PGP-Key-ID: 0x090B11993D9AEBB5 X-PGP-Key: http://www.fdn.fr/~lcourtes/ludovic.asc X-PGP-Fingerprint: 3CE4 6455 8A84 FDC6 9DB4 0CFB 090B 1199 3D9A EBB5 X-OS: x86_64-pc-linux-gnu Date: Thu, 04 Jun 2020 09:50:16 +0200 Message-ID: <87sgfbgthj.fsf@inria.fr> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.3 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-BeenThere: guix-devel@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "Development of GNU Guix and the GNU System distribution." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-devel-bounces+larch=yhetil.org@gnu.org Sender: "Guix-devel" X-Scanner: scn0 Authentication-Results: aspmx1.migadu.com; dkim=none; dmarc=none; spf=pass (aspmx1.migadu.com: domain of guix-devel-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=guix-devel-bounces@gnu.org X-Spam-Score: -1.01 X-TUID: aZLlab7JM0bH Hello! Here=E2=80=99s a followup to Andy=E2=80=99s great blog post about the new = =E2=80=9Cbaseline compiler=E2=80=9D that=E2=80=99ll be in Guile 3.0.3: https://wingolog.org/archives/2020/06/03/a-baseline-compiler-for-guile With the attached patch I=E2=80=99ve run =E2=80=98make as-derivation=E2=80= =99 (equivalent to =E2=80=98guix pull=E2=80=99) and timed the builds of guix-packages-base.drv= (279 files) and guix-packages.drv (217 files) on my 4-core i7 laptop: =E2=80=A2 guix-packages-base.drv: 1m30s (was 4m) =E2=80=A2 guix-packages.drv: 30s (was 1m8s) So this part is ~2.5 times faster than before, yay! Thank you, Andy! This is quite an achievement, especially given that, before compiling, there=E2=80=99s an initial phase during which we load all the files, and th= at phase is sequential and takes the same amount of time in both cases. For the record, the optimizations currently used in (guix build compile) are between the new -O0 and -O1: (cond ((or (string-contains file "gnu/packages/") (string-contains file "gnu/tests/")) ;; Level 0 is good enough but partial evaluation helps preserve the ;; "macro writer's bill of rights". (override-option #:partial-eval? #t (optimizations-for-level 0))) ((string-contains file "gnu/services/") ;; '-O2 -Ono-letrectify' compiles about ~20% faster than '-O2' for ;; large files like gnu/services/mail.scm. (override-option #:letrectify? #f (optimizations-for-level 2))) (else (optimizations-for-level 3))) With the new -O1, the scheme->tree-il conversion (mostly macro expansion) accounts for half of the build time on large files: --8<---------------cut here---------------start------------->8--- scheme@(guile-user)> ,use(system base optimize) scheme@(guile-user)> ,time (compile-file "gnu/packages/python-xyz.scm" #:op= ts (optimizations-for-level 1)) $1 =3D "/data/src/guile-3.0/cache/guile/ccache/3.0-LE-8-4.3/home/ludo/src/g= uix/gnu/packages/python-xyz.scm.go" ;; 4.154311s real time, 5.604945s run time. 2.538106s spent in GC. --8<---------------cut here---------------end--------------->8--- vs.: --8<---------------cut here---------------start------------->8--- scheme@(guile-user)> ,use(system base compile) scheme@(guile-user)> ,time (define t (call-with-input-file "gnu/packages/p= ython-xyz.scm" (lambda (port) (read-and-compile port #:to 'tree-il)))) ;; 2.206563s real time, 3.057369s run time. 1.339261s spent in GC. --8<---------------cut here---------------end--------------->8--- The profile looks like this: --8<---------------cut here---------------start------------->8--- scheme@(guile-user)> ,pr (define t (call-with-input-file "gnu/packages/pyt= hon-xyz.scm" (lambda (port) (read-and-compile port #:to 'tree-il)))) % cumulative self=20=20=20=20=20=20=20=20=20=20=20=20=20 time seconds seconds procedure 13.16 0.45 0.40 anon #x1136458 10.53 0.35 0.32 ice-9/popen.scm:168:0:reap-pipes 7.89 0.24 0.24 anon #x1132af8 6.14 0.35 0.19 ice-9/boot-9.scm:3128:0:module-gensym 5.26 0.21 0.16 ice-9/boot-9.scm:2201:0:%load-announce 4.39 0.19 0.13 ice-9/psyntax.scm:749:8:search 3.51 0.69 0.11 ice-9/psyntax.scm:2964:6:match* 3.51 0.11 0.11 anon #x11334e8 3.51 0.11 0.11 anon #x1136428 2.63 0.08 0.08 anon #x113a258 1.75 0.05 0.05 ice-9/psyntax.scm:3017:12:$sc-dispatch 1.75 0.05 0.05 anon #x1139e68 0.88 277.30 0.03 ice-9/boot-9.scm:220:5:map1 --8<---------------cut here---------------end--------------->8--- It=E2=80=99d be great to waive the anonymity of that first lambda. :-) I was wondering what fraction of that time was spent running Guix macros (=E2=80=98package=E2=80=99, =E2=80=98base32=E2=80=99, and so on), but it=E2= =80=99s difficult to answer that question here. Probably something to investigate so we can make further progress! Ludo=E2=80=99.