From: Linas Vepstas <linasvepstas@gmail.com>
To: Arne Babenhauserheide <arne_bab@web.de>
Cc: "guile-user@gnu.org" <guile-user@gnu.org>
Subject: Re: out-of-control GC
Date: Sun, 10 Sep 2017 15:23:19 -0500 [thread overview]
Message-ID: <CAHrUA34t6LKoLT3LNT3sHR5RBdh9DJ9u0afDrPHEQzn86i2dcQ@mail.gmail.com> (raw)
In-Reply-To: <87zia28phj.fsf@web.de>
Hi Arne,
On Sun, Sep 10, 2017 at 11:50 AM, Arne Babenhauserheide <arne_bab@web.de>
wrote:
> Hi Linas,
>
>
> Linas Vepstas <linasvepstas@gmail.com> writes:
>
> > To make this conversation less crazy, and more down-to-earth, here is a
> > demo that seems to spend most of its time in GC. Hard for me to to say
> that
> > this is "wrong", right now, but it illustrates the scandalous nature of
> the
> > problem.
>
> Do you have many string operations in your code?
>
> If I replace
>
> (cons (format #f "~A" cnt) lis)
>
> with
>
> (cons cnt lis)
>
> GC is down to ~20% (from around 130%).
>
That demo tried to capture the spirit of a more complex system. The cons
that I have is actually (cons (wrapper-for-some-c++-code foobar) lis) or
maybe (cons (scheme-that-calls-other-scheme-that-calls-c++ foo) lis) ...
but its not just cons -- it can also be for-each, map, or fold.
The actual printouts, in my instrumented code look like this:
guile-en-r> (avg-gc-cpu-time)
Elapsed: 4461. secs. Rate: 4.236 gc/min %cpu-GC: 280.8% %cpu-use: 284.0%
guile-en-r> (avg-gc-cpu-time)
Elapsed: 1501. secs. Rate: 4.077 gc/min %cpu-GC: 280.4% %cpu-use: 283.8%
guile-en-r> (gc-stats)
((gc-time-taken . 353452428102078) (heap-size . 6485340160) (heap-free-size
. 3497791488) (heap-total-allocated . 100778445248)
(heap-allocated-since-gc . 9248) (protected-objects . 7) (gc-times . 12894))
which suggests that the vast majority of time is spent in GC, and not in
either scheme/guile, or my wrapped c++ code.
4 gc's/minute means one every 15 seconds, which sounds reasonable, except
that RAM usage is so huge, that each GC takes many seconds to complete. By
examining heap-free-size before and after, there is almost no change --
i.e. there was very little to collect. Hmm .. perhaps I should monitor
that more closely, to see how true that really is ...
Anyway, this demo gives a scenario where gc seems to run too often. I have
other scenarios where it does not run often enough -- I have one where the
working set is about 200MBytes, but guile happily grows to 10GB or 20GB RAM
over a few hours. My solution for that other case is to manually GC
whenever gc-stats gets above 1GB, because I know a priori my working set is
smaller than that.
The overall message seems to be that gc either runs too often, or not often
enough. Some sort of better planning is needed.
I'm motivated to explore this, as it actually impacts my work.
--linas
--
*"The problem is not that artificial intelligence will get too smart and
take over the world," computer scientist Pedro Domingos writes, "the
problem is that it's too stupid and already has." *
next prev parent reply other threads:[~2017-09-10 20:23 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-09-09 19:47 out-of-control GC Linas Vepstas
2017-09-10 4:14 ` Linas Vepstas
2017-09-10 16:50 ` Arne Babenhauserheide
2017-09-10 18:03 ` David Kastrup
2017-09-10 20:23 ` Linas Vepstas [this message]
2017-09-10 20:36 ` Marko Rauhamaa
2017-09-10 21:47 ` Linas Vepstas
2017-09-10 22:38 ` Marko Rauhamaa
2017-09-11 16:17 ` Arne Babenhauserheide
2017-09-14 18:31 ` Linas Vepstas
2017-09-14 18:58 ` Marko Rauhamaa
2017-09-14 20:15 ` Linas Vepstas
2017-09-14 20:36 ` David Kastrup
2017-09-14 20:45 ` Arne Babenhauserheide
2017-09-11 8:22 ` tomas
2017-09-14 20:19 ` Linas Vepstas
2017-09-13 17:13 ` David Kastrup
2017-09-10 22:17 ` Arne Babenhauserheide
2017-09-10 22:36 ` Arne Babenhauserheide
2017-09-14 7:44 ` Mark H Weaver
2017-09-10 16:53 ` Arne Babenhauserheide
2017-09-13 2:24 ` Mark H Weaver
2017-09-13 19:38 ` Arne Babenhauserheide
2017-09-13 19:57 ` David Kastrup
2017-09-13 20:37 ` Arne Babenhauserheide
2017-09-14 19:14 ` Linas Vepstas
2017-09-11 18:13 ` Hans Åberg
-- strict thread matches above, loose matches on Subject: below --
2017-09-11 7:42 Kjetil Matheussen
2017-09-14 18:41 ` Linas Vepstas
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=CAHrUA34t6LKoLT3LNT3sHR5RBdh9DJ9u0afDrPHEQzn86i2dcQ@mail.gmail.com \
--to=linasvepstas@gmail.com \
--cc=arne_bab@web.de \
--cc=guile-user@gnu.org \
/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).