[ruby-core:32788] Re: [Ruby 1.9-Feature#3436] Spawn the timer thread lazily

From: Mark Somerville <mark@...>
Date: 2010-10-14 15:45:33 UTC
List: ruby-core #32788
Hi Koichi,

On Wed, Oct 13, 2010 at 11:40:52PM +0900, SASADA Koichi wrote:
> It is tough for me to describe the behavior in English.

OK.

> ex) How to wake up the thread?
> 
>     check_signal();
>       <- receive signal at this timing
>     select(..., infinitely);

Would this occur if rb_signal_buff_size() > 1 and we process a signal
with a handler that calls a blocking function?

> (2) Performance issue.  Your patch start/kill the timer thread.  In
> general, the native thread creation/deletion cause some performance issue.

I assumed (perhaps incorrectly) that the overhead was small enough and
the creation and deletion uncommon enough that it wouldn't be a problem.

Perhaps there could be a method of increasing the time the timer thread
waits if rb_thread_alone() and creation of a new thread could reduce
this again.

> I understand your issue.  In fact, I'm considering this problem and
> seeking the solution in recent months.

It seems to me that we are attempting different things. I have been
primarily concerned with reducing/removing CPU wakeups in the
single-threaded case and falling back to the timer thread when
multi-threaded. Assuming, I understand you correcly, you appear to be
trying to remove the timer thread completely.

If you are trying to remove the timer thread altogether, that's
*great* news and I won't bother carrying this patch on!

> Could you wait for some days?  I may show the another idea.

Sure. I'll be interested to see it!
 
> BTW, recent python solve with some clever (complex, for me) method.
> http://www.dabeaz.com/python/UnderstandingGIL.pdf

Really interesting reading.

Thanks a lot, very useful!

In This Thread