ruby-core@ruby-lang.org archive (unofficial mirror)
 help / color / mirror / Atom feed
From: SASADA Koichi <ko1@atdot.net>
To: ruby-core@ruby-lang.org
Subject: [ruby-core:61508] Re: [REJECT?] xmalloc/xfree: reduce atomic ops w/ thread-locals
Date: Sat, 15 Mar 2014 16:15:29 +0900	[thread overview]
Message-ID: <5323FE11.3000908@atdot.net> (raw)
In-Reply-To: <20140313171243.GA10468@dcvr.yhbt.net>

(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.


>> > # 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.


BTW,

> +    rb_thread_t *th = ruby_thread_from_native();

`th' can be NULL because no Ruby threads can call this code.

-- 
// SASADA Koichi at atdot dot net

  parent reply	other threads:[~2014-03-15  7:18 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     ` SASADA Koichi [this message]
2014-03-15  8:34       ` [ruby-core:61509] " Eric Wong
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=5323FE11.3000908@atdot.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).