From: SASADA Koichi Date: 2014-03-15T16:15:29+09:00 Subject: [ruby-core:61508] Re: [REJECT?] xmalloc/xfree: reduce atomic ops w/ thread-locals (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