From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp2 ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms11 with LMTPS id sHUIMRWw2l5qRgAA0tVLHw (envelope-from ) for ; Fri, 05 Jun 2020 20:50:29 +0000 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp2 with LMTPS id CDXcLBWw2l6LfAAAB5/wlQ (envelope-from ) for ; Fri, 05 Jun 2020 20:50:29 +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 4DC5A94050A for ; Fri, 5 Jun 2020 20:50:29 +0000 (UTC) Received: from localhost ([::1]:38768 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jhJIK-0002MC-5U for larch@yhetil.org; Fri, 05 Jun 2020 16:50:28 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43378) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jhJI7-0002LI-Gt; Fri, 05 Jun 2020 16:50:15 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]:46486) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jhJI5-0006Tn-Fb; Fri, 05 Jun 2020 16:50:13 -0400 Received: from [2a01:e0a:1d:7270:af76:b9b:ca24:c465] (port=50750 helo=ribbon) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1jhJI4-0000rA-Mk; Fri, 05 Jun 2020 16:50:13 -0400 From: =?utf-8?Q?Ludovic_Court=C3=A8s?= To: Guile Devel , Andy Wingo Subject: The size of =?utf-8?B?4oCYLmdv4oCZ?= files X-URL: http://www.fdn.fr/~lcourtes/ X-Revolutionary-Date: 18 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: Fri, 05 Jun 2020 22:50:10 +0200 Message-ID: <875zc5z18d.fsf@gnu.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.3 (gnu/linux) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" 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: , Cc: guix-devel 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: -0.01 X-TUID: fggpNPs93mFi --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Hello Guix! On IRC there was a discussion about the size of =E2=80=98.go=E2=80=99 files= . The discussion came from this observation: --8<---------------cut here---------------start------------->8--- $ guix size $(readlink -f /run/current-system) | head -5 store item total s= elf /gnu/store/4d0p06xgaw8lqa9db0d6728kkba8bizj-qemu-5.0.0 1651.6 = 745.2 18.8% /gnu/store/abiva5ivq99x30r2s9pa3jj0pv9g16sv-guix-1.1.0-4.bdc801e 468.0 = 268.8 6.8% /gnu/store/111zp1qyind7hsnvrm5830jhankmx4ls-linux-libre-5.4.43 243.6 = 243.6 6.2% /gnu/store/skxkrhgn9z0fg9hmnbcyfdgzs5w4ryrr-llvm-9.0.1 199.9 = 128.5 3.2% --8<---------------cut here---------------end--------------->8--- On disk, those .go files take quite a bit of space (I hear you Btrfs people, don=E2=80=99t say it! :-)). The code snippet below sorts the ELF sections of a .go file by size; for =E2=80=98python-xyz.go=E2=80=99, I get this: --8<---------------cut here---------------start------------->8--- $13 =3D ((".rtl-text" . 3417108) (".guile.arities" . 1358536) (".data" . 586912) (".rodata" . 361599) (".symtab" . 117000) (".debug_line" . 97342) (".debug_info" . 54519) (".guile.frame-maps" . 47114) ("" . 1344) (".guile.arities.strtab" . 681) ("" . 232) (".shstrtab" . 229) (".dynamic" . 112) (".debug_str" . 87) (".strtab" . 75) (".debug_abbrev" . 65) (".guile.docstrs.strtab" . 1) ("" . 0) (".guile.procprops" . 0) (".guile.docstrs" . 0) (".debug_loc" . 0)) scheme@(guile-user)> (stat:size (stat go)) $14 =3D 6083445 --8<---------------cut here---------------end--------------->8--- More than half of those 6=C2=A0MiB is code, and more than 1=C2=A0MiB is =E2=80=9C.guile.arities=E2=80=9D (info "(guile) Object File Format"), which= is surprisingly large; presumably the file only contains thunks (the =E2=80=98thunked=E2=80=99 fields of ). Stripping the .debug_* sections (if that works) clearly wouldn=E2=80=99t he= lp. So I guess we could generate less code (reduce =E2=80=98.rtl-text=E2=80=99)= , perhaps by tweaking =E2=80=98define-record-type*=E2=80=99, but I have little hope ther= e. We could also investigate where =E2=80=9C.guile.arities=E2=80=9D could be m= ade denser, or use fewer thunked fields in . Currently arity info takes 7x4 =3D 28 bytes per procedure as documented in (system vm assembler). With an extra flag we could perhaps save 8 bytes for the simple case where nopt =3D 0, nreq is small, and other flags are zero. But anyway, currently there are (1358536 - 4) / 28 =3D 48K arity headers in this file. However, the file contains 970 packages, so we=E2=80=99re ta= lking about ~50 procedures per package, even though there are only 5 thunked fields. Weird! Maybe I=E2=80=99m missing something. But wait, that was with 3.0.2 and -O1. With 3.0.3-to-be and -O1, python-xyz.go weighs in at 3.4=C2=A0MiB instead of 5.9=C2=A0MiB! Here=E2=80=99s the section size distribution: --8<---------------cut here---------------start------------->8--- $4 =3D ((".rtl-text" . 2101168) (".data" . 586392) (".rodata" . 360703) (".guile.arities" . 193106) (".symtab" . 117000) (".debug_line" . 76685) (".debug_info" . 53513) ("" . 1280) (".guile.arities.strtab" . 517) ("" . 232) (".shstrtab" . 211) (".dynamic" . 96) (".debug_str" . 87) (".strtab" . 75) (".debug_abbrev" . 56) (".guile.docstrs.strtab" . 1) ("" . 0) (".guile.procprops" . 0) (".guile.docstrs" . 0) (".debug_loc" . 0)) scheme@(guile-user)> (stat:size (stat go)) $5 =3D 3519323 --8<---------------cut here---------------end--------------->8--- =E2=80=9C.rtl-text=E2=80=9D is 38% smaller and =E2=80=9C.guile.arities=E2= =80=9D is almost a tenth of what it was. Something=E2=80=99s going on here! Thoughts? Ludo=E2=80=99. --=-=-= Content-Type: text/plain Content-Disposition: inline; filename=elf-size.scm Content-Description: the code (use-modules (system vm elf) (rnrs io ports) (ice-9 match)) (define go (search-path %load-compiled-path "gnu/packages/python-xyz.go")) (define elf (parse-elf (call-with-input-file go get-bytevector-all))) (define (elf-section-name-as-string elf section) (let ((off (elf-section-offset (list-ref (elf-sections elf) (elf-shstrndx elf))))) (string-table-ref (elf-bytes elf) (+ off (elf-section-name section))))) (sort (map (lambda (section) (cons (elf-section-name-as-string elf section) (elf-section-size section))) (elf-sections elf)) (match-lambda* (((name1 . size1) (name2 . size2)) (> size1 size2)))) --=-=-=--