unofficial mirror of guile-devel@gnu.org 
 help / color / mirror / Atom feed
From: Mark H Weaver <mhw@netris.org>
To: Linas Vepstas <linasvepstas@gmail.com>
Cc: Guile User <guile-user@gnu.org>, Guile Development <guile-devel@gnu.org>
Subject: Re: guile-2.9.2 and threading
Date: Fri, 07 Jun 2019 01:01:55 -0400	[thread overview]
Message-ID: <87d0jqasyp.fsf@netris.org> (raw)
In-Reply-To: <87h892ault.fsf@netris.org> (Mark H. Weaver's message of "Fri, 07 Jun 2019 00:26:27 -0400")

Mark H Weaver <mhw@netris.org> writes:

>> Two are stuck here:
>>
>> #0  __lll_lock_wait () at ../sysdeps/unix/sysv/linux/x86_64/lowlevellock.S:135
>> #1  0x00007f343ca69bb5 in __GI___pthread_mutex_lock (
>>     mutex=mutex@entry=0x7f343d4f0f40 <bytes_until_gc_lock>)
>>     at ../nptl/pthread_mutex_lock.c:80
>> #2  0x00007f343d213e20 in scm_gc_register_allocation (size=size@entry=16)
>>     at ../../libguile/gc.c:591
>
> This is the global GC allocation lock, which might be an issue if your
> threads are performing a lot of heap allocation.

Sorry, I spoke too quickly here, although what I wrote is not far from
the truth.  'bytes_until_gc_lock' is used by Guile to protect its global
counter of how much plain 'malloc' memory has been allocated since the
last garbage collection.  Once it reaches a certain threshold, a garbage
collection is forced.

Why do we have this?  Sometimes the GC heap contains a large number of
small collectible objects which reference much larger objects in plain
'malloc' memory.  For example, this can happen if you're creating a lot
of bignums, which are small GC objects pointing to digit data stored in
'malloc' memory.  The garbage collector doesn't trigger because there's
plenty of free memory in the GC heap, and it doesn't know that those
small objects are keeping alive much larger objects elsewhere.

However, if this particular lock is a pain point for you, there are
things we could do to improve this.  One idea that comes to mind is to
keep smaller per-thread counters, which are only added to the global
counter after they reach a certain threshold value.  In this case, we
don't need a precise global count.

        Mark



  reply	other threads:[~2019-06-07  5:01 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-06-02 23:25 guile-2.9.2 and threading Linas Vepstas
2019-06-07  4:26 ` Mark H Weaver
2019-06-07  5:01   ` Mark H Weaver [this message]
2019-07-09 20:46   ` Linas Vepstas
2019-07-14 21:59     ` Now crashing [was " Linas Vepstas
2019-07-14 22:03       ` Linas Vepstas
2019-07-15  3:03         ` Linas Vepstas
2019-07-17 16:27           ` Linas Vepstas
2019-07-17 17:47             ` Mark H Weaver
2019-07-17 21:44               ` Linas Vepstas
2019-07-18  1:42                 ` Linas Vepstas
2019-07-18  3:52                   ` Linas Vepstas
2019-07-21 21:10                     ` Linas Vepstas
2019-08-05 18:07                       ` Mark H Weaver
2019-08-07 16:05                         ` 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=87d0jqasyp.fsf@netris.org \
    --to=mhw@netris.org \
    --cc=guile-devel@gnu.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).