unofficial mirror of guile-devel@gnu.org 
 help / color / mirror / Atom feed
From: ludo@gnu.org (Ludovic Courtès)
To: guile-devel <guile-devel@gnu.org>, Andy Wingo <wingo@igalia.com>
Subject: Re: Compiler memory consumption
Date: Wed, 25 Oct 2017 10:42:40 -0700	[thread overview]
Message-ID: <87po9bjf8v.fsf@gnu.org> (raw)
In-Reply-To: <87wp54z3p5.fsf@gnu.org> ("Ludovic \=\?utf-8\?Q\?Court\=C3\=A8s\=22'\?\= \=\?utf-8\?Q\?s\?\= message of "Tue, 12 Sep 2017 11:06:14 +0200")

Hello,

An update on this…

ludo@gnu.org (Ludovic Courtès) skribis:

> This is a followup to the compiler issue, this time focusing on
> execution time, trying to see why the compiler takes so long to compile
> gnu/packages/*.scm, which should be trivial.
> 
> As a test bed, I built this from the Guix tree:
> 
>   GUILE_LOAD_COMPILED_PATH=$PWD guild compile \
>     -L $PWD -o t.cps --to=cps gnu/packages/python.scm
> 
> This results in a 428,185-line file, with that many CPS labels.

[...]

> The intmap ‘big-cps’ has those 428K elements distributed in 13,814
> 33-element vectors (per ‘intmap-vector-count’ in the attached file.)
>
> I fail to see why we’re GC’ing so much (‘visit-branch’ is also first in
> the GC profile).

To get a clearer idea of where memory consumption comes from, I added
‘format’ calls at several points in ‘emit-bytecode’ and its callees,
while compiling again the big CPS above.

‘emit-bytecode’ starts by computing reachable functions.  The first of
these is the top-level thunk, which encompasses everything (all 428K
labels.)

On the first ‘allocate-slots’ call, memory consumption grows from ~500M
to 1300M; most of this comes from ‘compute-live-variables’, which is
also responsible for a large chunk of the run time.

In short, compiling the top-level thunk is what’s killing us, because
the space and time complexity is proportional to the number of labels
therein.

Also, our 16K line python.scm file translates into 428K labels, which
during slot allocation translates into a dozen of 428K-element intmaps
and intsets.  So the compilation cost is space per source line of code
is high.

Andy, what are your thoughts?

TIA,
Ludo’.



  parent reply	other threads:[~2017-10-25 17:42 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-05-16 16:19 Compiler memory consumption Ludovic Courtès
2017-05-16 20:14 ` Andy Wingo
2017-05-16 20:45   ` Ludovic Courtès
2017-09-12  9:06   ` Ludovic Courtès
2017-09-17 13:56     ` Weak tables harmful to GC? Ludovic Courtès
2017-10-09 13:10       ` Christopher Allan Webber
2017-10-22  1:52       ` Ludovic Courtès
2017-10-22  2:20         ` Christopher Allan Webber
2017-10-23  0:16           ` Ludovic Courtès
2017-10-24 15:02             ` Ricardo Wurmus
2017-10-24 15:32             ` Ricardo Wurmus
2017-10-25  6:38               ` Ricardo Wurmus
2017-10-26  7:03               ` Ludovic Courtès
2017-10-26  8:35                 ` Ricardo Wurmus
2017-10-26 16:52                   ` Ricardo Wurmus
2017-10-27  5:28                     ` Ludovic Courtès
2017-10-28  9:56                       ` Ricardo Wurmus
2017-10-30 12:35                         ` Ludovic Courtès
2017-10-30 14:48                           ` Ricardo Wurmus
2017-10-30 17:20                             ` Ricardo Wurmus
2017-10-30 22:18                               ` Ludovic Courtès
2017-10-30 17:29                           ` bug#19180: " Andy Wingo
2017-10-30 23:13                             ` Ludovic Courtès
2017-10-31  8:25                               ` Andy Wingo
2017-10-31 16:56                                 ` Ludovic Courtès
2017-10-26 17:17                   ` Ludovic Courtès
2017-10-24 22:45             ` Christopher Allan Webber
2017-10-24 22:58               ` Ludovic Courtès
2017-10-25  0:50                 ` Christopher Allan Webber
2017-10-25 17:11                   ` Ludovic Courtès
2017-10-25 17:42     ` Ludovic Courtès [this message]
2017-10-30 15:16       ` Compiler memory consumption Andy Wingo
2017-10-30 15:52         ` Ludovic Courtès

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=87po9bjf8v.fsf@gnu.org \
    --to=ludo@gnu.org \
    --cc=guile-devel@gnu.org \
    --cc=wingo@igalia.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).