unofficial mirror of bug-guile@gnu.org 
 help / color / mirror / Atom feed
From: Linas Vepstas <linasvepstas@gmail.com>
To: 25386@debbugs.gnu.org
Subject: bug#25386: Manual gc helps
Date: Sat, 7 Jan 2017 20:57:26 -0600	[thread overview]
Message-ID: <CAHrUA34uETQdmePeO+vr3bU-V3T9TSiPgdx7ePM34ZaBuwKfQg@mail.gmail.com> (raw)
In-Reply-To: <CAHrUA36ZAxeC1nYZQfTLBXGDK1XciNHkEafPuQ+VqzZXASOwcw@mail.gmail.com>

I did a fairly through review of the thread-creation and thread-join
code in the git master branch, and it looks to be just fine. Thus,
some experimentation is in order:

Going back to guile-2.0, I see this behavior:
guile -v
guile (GNU Guile) 2.0.11
Packaged by Debian (2.0.11-deb+1-10)

If I add a manual gc to the exit of the thread, like so:

   (define (mkthr v) (call-with-new-thread (lambda ()
         (set! junk (+ junk 1)) (gc) )))

then the heap blows up, in minutes, to about 180MB but then stops
growing, even after hours and millions of thread creates:
(heap-size . 183734272) (gc-times . 1957954)

If I gc only every third thread create, it quickly blows up to about
400MB, and then stablizes, for hours:
(heap-size . 428638208) (gc-times . 1292663)

If I gc every 17th thread, it blows up to about 1.8GB and then is stable:
(heap-size . 1875902464) (gc-times . 327462)

This last one after about 5.5 million thread creates and joins.
The counting is done like so:

   (define (mkthr v) (call-with-new-thread (lambda ()
                (lock-mutex mtx)
                (if (eq? 0 (modulo junk 17)) (gc))
                (set! junk (+ junk 1))
                (unlock-mutex mtx)
                )))

In each case, it seems to hit a plateau at about (n+1)*100MB when gc
is done on one out of every n threads.  This seems quite bizarre to
me: why does this inverted relation on number of gcs vs number of
thread creates? What's magic about 100MB? Clearly 100MB is wayyy too
large for this very simple program.  I mean, even if I gc at *every*
thread-exit ...

(I have not yet explored above in guile-2.2)

Since I cannot find any 'obvious' bugs in guile, this suggests some
strange stochastic behavior in bdw-gc?





  reply	other threads:[~2017-01-08  2:57 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-01-07 21:47 bug#25386: guile-2.0 and 2.2 thread leakage+crash; very simple test attached Linas Vepstas
2017-01-08  2:57 ` Linas Vepstas [this message]
2017-01-08 14:57 ` bug#25386: test case update Linas Vepstas
2017-01-08 21:55 ` bug#25386: calling gc too often triggers a crash Linas Vepstas
2017-01-09  1:28 ` bug#25386: Please ignore previous stack trace Linas Vepstas
2017-01-11  6:14 ` bug#25386: This can be closed Linas Vepstas
2017-03-01 15:31   ` Andy Wingo

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=CAHrUA34uETQdmePeO+vr3bU-V3T9TSiPgdx7ePM34ZaBuwKfQg@mail.gmail.com \
    --to=linasvepstas@gmail.com \
    --cc=25386@debbugs.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).