From: "Ludovic Courtès" <ludo@gnu.org>
To: guile-devel@gnu.org, Andy Wingo <wingo@pobox.com>
Subject: The case for more macro-instructions?
Date: Wed, 17 Apr 2024 15:26:53 +0200 [thread overview]
Message-ID: <871q74i0gy.fsf@inria.fr> (raw)
Hi Andy and all,
Looking at the disassembly of -O1 code in a quest for more concise
bytecode¹ (a quest that’s not necessarily always relevant but probably
is at -O1), I noticed a few things:
1. Code for free variable lookup, emitted by
‘emit-cached-toplevel-box’, is too large (~7 instructions per
variable) for little in return.
2. The ‘.data’ section is surprisingly large: for each symbol in the
source, we end up in that section with a string, a stringbuf
(pointing to contents in the ‘.rodata’ section), and a symbol.
More on that below.
3. ‘*lcm-page-size*’ is set to 64 KiB for the purposes of reducing the
number of .go variants needed under prebuilt/.
Should we default to sysconf(_SC_PAGESIZE) and use that common
denominator only when building .go files under prebuilt/ (this
requires adding a compiler flag to choose a different alignment)?
(In the meantime, I changed the linker to create sparse files in
commit 112b617f5921c67b4b2c45aae39f54cccd34d7ef.)
Regarding ‘.data’, look:
--8<---------------cut here---------------start------------->8---
$ echo sym > /tmp/t.scm
$ ./meta/uninstalled-env guild compile /tmp/t.scm -o /tmp/t.go
wrote `/tmp/t.go'
$ readelf -a /tmp/t.go |grep -A10 "^Section Headers"
readelf: Warning: [ 5]: Link field (0) should index a string section.
readelf: Warning: local symbol 0 found at index >= .symtab's sh_info value of 0
readelf: Warning: local symbol 1 found at index >= .symtab's sh_info value of 0
Section Headers:
[Nr] Name Type Address Offset
Size EntSize Flags Link Info Align
[ 0] NULL 0000000000000000 00000000
0000000000000000 0000000000000000 0 0 0
[ 1] .guile.procprops PROGBITS 0000000000000000 00010588
0000000000000000 0000000000000000 0 0 8
[ 2] .rodata PROGBITS 0000000000000158 00000158
0000000000000014 0000000000000000 A 0 0 8
[ 3] .data PROGBITS 0000000000010000 00010000
0000000000000058 0000000000000000 WA 0 0 8
--8<---------------cut here---------------end--------------->8---
That’s 88 bytes for ‘.data’.
If ‘lookup-bound’ would take a string (instead of a symbol) like
‘lookup-bound-private’ and ‘lookup-bound-public’ do, we’d save
relocations and space.
Perhaps these instructions (or rather variants thereof) could even take
a raw UTF-8 buffer instead?
As for #1, I’m not sure what the best option is. I initially thought
about adding a new macro-instruction, but then we’d lose on cache-hit
path, which is not good.
Thoughts?
Ludo’.
¹ https://issues.guix.gnu.org/70398
next reply other threads:[~2024-04-17 13:26 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-04-17 13:26 Ludovic Courtès [this message]
2024-04-17 20:34 ` The case for more macro-instructions? Maxime Devos
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/guile/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=871q74i0gy.fsf@inria.fr \
--to=ludo@gnu.org \
--cc=guile-devel@gnu.org \
--cc=wingo@pobox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).