unofficial mirror of guile-user@gnu.org 
 help / color / mirror / Atom feed
From: Mark H Weaver <mhw@netris.org>
To: Linas Vepstas <linasvepstas@gmail.com>
Cc: guile-user@gnu.org
Subject: Re: out-of-control GC
Date: Thu, 14 Sep 2017 03:44:59 -0400	[thread overview]
Message-ID: <87h8w52078.fsf@netris.org> (raw)
In-Reply-To: <CAHrUA34t6LKoLT3LNT3sHR5RBdh9DJ9u0afDrPHEQzn86i2dcQ@mail.gmail.com> (Linas Vepstas's message of "Sun, 10 Sep 2017 15:23:19 -0500")

Linas Vepstas <linasvepstas@gmail.com> writes:
> The overall message seems to be that gc either runs too often, or not often
> enough.  Some sort of better planning is needed.

There several variables available to adjust libgc's heuristics, e.g.
GC_use_entire_heap, GC_free_space_divisor, GC_full_frequency, with
associated environment variables, described in:
<https://github.com/ivmai/bdwgc/blob/master/doc/README.environment>

> I'm motivated to explore this, as it actually impacts my work.

If you'd like to learn how Boehm GC decides when to run, I would
encourage you to read <http://www.hboehm.info/gc/gcdescr.html>.  I've
selected some relevant excerpts below.

      Mark


http://www.hboehm.info/gc/gcdescr.html

[...]
  In non-incremental mode, we make a decision about whether to garbage
  collect whenever an allocation would otherwise have failed with the
  current heap size. If the total amount of allocation since the last
  collection is less than the heap size divided by GC_free_space_divisor,
  we try to expand the heap. Otherwise, we initiate a garbage
  collection. This ensures that the amount of garbage collection work per
  allocated byte remains constant.
  
  The above is in fact an oversimplification of the real heap expansion
  and GC triggering heuristic, which adjusts slightly for root size and
  certain kinds of fragmentation. In particular:
  
  * Programs with a large root set size and little live heap memory will
    expand the heap to amortize the cost of scanning the roots.
  
  * Versions 5.x of the collector actually collect more frequently in
    nonincremental mode. The large block allocator usually refuses to
    split large heap blocks once the garbage collection threshold is
    reached. This often has the effect of collecting well before the heap
    fills up, thus reducing fragmentation and working set size at the
    expense of GC time. Versions 6.x choose an intermediate strategy
    depending on how much large object allocation has taken place in the
    past. (If the collector is configured to unmap unused pages, versions
    6.x use the 5.x strategy.)
  
  * In calculating the amount of allocation since the last collection we
    give partial credit for objects we expect to be explicitly
    deallocated. Even if all objects are explicitly managed, it is often
    desirable to collect on rare occasion, since that is our only
    mechanism for coalescing completely empty chunks.
  
  It has been suggested that this should be adjusted so that we favor
  expansion if the resulting heap still fits into physical memory. In many
  cases, that would no doubt help. But it is tricky to do this in a way
  that remains robust if multiple application are contending for a single
  pool of physical memory.

[...]

  In incremental mode, the heap is always expanded when we encounter
  insufficient space for an allocation. Garbage collection is triggered
  whenever we notice that more than GC_heap_size/2 *
  GC_free_space_divisor bytes of allocation have taken place. After
  GC_full_freq minor collections a major collection is started.



  parent reply	other threads:[~2017-09-14  7:44 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
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 [this message]
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=87h8w52078.fsf@netris.org \
    --to=mhw@netris.org \
    --cc=guile-user@gnu.org \
    --cc=linasvepstas@gmail.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).