ruby-core@ruby-lang.org archive (unofficial mirror)
 help / color / mirror / Atom feed
From: Eric Wong <normalperson@yhbt.net>
To: Ruby developers <ruby-core@ruby-lang.org>
Subject: [ruby-core:61509] Re: [REJECT?] xmalloc/xfree: reduce atomic ops w/ thread-locals
Date: Sat, 15 Mar 2014 08:34:51 +0000	[thread overview]
Message-ID: <20140315083451.GA24736@dcvr.yhbt.net> (raw)
In-Reply-To: <5323FE11.3000908@atdot.net>

SASADA Koichi <ko1@atdot.net> wrote:
> (2014/03/14 2:12), Eric Wong wrote:
> > How about only using thread local and remove the process-wide globals?
> 
> I doubt
> 
> > Underflow from race conditions might cause too many GC runs.
> 
> Let the counter(s) change addition only.
> 
> separate then into:
>   malloc_increase (increase only)
>   free_increase   (increase only)
> 
> and use like that:
>   if (malloc_incraese > free_increase &&
>       malloc_incraese - free_increase > malloc_limit) {
>     do_gc();
>   }
> 
> There are no underflow.
> 
> In fact, I started this strategy just before releasing 2.1. However,
> "free_increase" is bigger than malloc_increase.  Maybe this is someone's
> bug (for example, xfree for a malloced block) or my misunderstanding.

That probably works since it's a fuzzy hint counter anyways.

You may have hit xcalloc having no increase:
http://bogomips.org/ruby.git/patch?id=08fc03c25615
(maybe malloc_usable_size is broken on some systems w/ calloc ...)

> >> > # basically, GVL protects multi-threads parallel update of such values.
> >> > # this atomic operations only for call_without_gvl().
> >> > # so it is minor case.
> > Right.  I am looking into using GVL less :)
> > For example, much of sweep phase may be done without GVL.
> 
> I see. It is problem.
> 
> # But parallel sweep on my exepriment doesn't show impressive speedup.

:<   Were there also regressions?

I wonder if the speedup would be bigger if we use an allocator with
good MT scalability.

> BTW,
> 
> > +    rb_thread_t *th = ruby_thread_from_native();
> 
> `th' can be NULL because no Ruby threads can call this code.

Did you mean: gsub(/no Ruby/, "non-Ruby") ?
I should put a FATAL exit there (but not much different than crashing).

  reply	other threads:[~2014-03-15  8:38 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-03-12  0:06 [ruby-core:61424] [REJECT?] xmalloc/xfree: reduce atomic ops w/ thread-locals Eric Wong
2014-03-12  0:09 ` [ruby-core:61425] " Charlie Somerville
2014-03-12  1:07 ` [ruby-core:61426] " Eric Wong
2014-03-13 13:29 ` [ruby-core:61466] " SASADA Koichi
2014-03-13 17:12   ` [ruby-core:61471] " Eric Wong
2014-03-14  6:20     ` [ruby-core:61488] " Eric Wong
2014-03-15  7:15     ` [ruby-core:61508] " SASADA Koichi
2014-03-15  8:34       ` Eric Wong [this message]
2014-03-15  9:27         ` [ruby-core:61510] " SASADA Koichi
2014-03-15 20:41           ` [ruby-core:61519] " Eric Wong
2014-03-20  4:23             ` [ruby-core:61604] " SASADA Koichi
2014-03-20  8:12             ` [ruby-core:61608] " SASADA Koichi
2014-03-20  8:13               ` [ruby-core:61609] " SASADA Koichi

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-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.ruby-lang.org/en/community/mailing-lists/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20140315083451.GA24736@dcvr.yhbt.net \
    --to=ruby-core@ruby-lang.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).