Forum: Ruby-core Fwd: ko1:r36433 (trunk): * thread.c (rb_thread_call_without_gvl2): added.

Posted by SASADA Koichi (Guest)
on 2012-07-18 08:54
(Received via mailing list)
Hi,

I introduced new API rb_thread_call_without_gvl2() with some documents.
 Could you review it?

# Of course, the name foo2() is not good.
# But I can't make good name for it.
# Good name is welcome.

Thanks,
Koichi

-------- Original Message --------
Subject: [ruby-cvs:43609] ko1:r36433 (trunk): * thread.c
(rb_thread_call_without_gvl2): added.
Date: Wed, 18 Jul 2012 15:47:44 +0900 (JST)
From: ko1@ruby-lang.org
Reply-To: ruby-dev@ruby-lang.org
To: ruby-cvs@ruby-lang.org

ko1  2012-07-18 15:47:43 +0900 (Wed, 18 Jul 2012)

  New Revision: 36433

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=r...

  Log:
    * thread.c (rb_thread_call_without_gvl2): added.
      it can skip last CHECK_INTS.  See document for more details.
      Document about it was updated a bit.
    * include/ruby/thread.h (decl. of rb_thread_call_without_gvl2): 
added.
    * thread.c (rb_thread_call_with_gvl): remove "EXPERIMENTAL!"
      warning from a document.

  Modified files:
    trunk/ChangeLog
    trunk/include/ruby/thread.h
    trunk/thread.c
Posted by Eric Wong (Guest)
on 2012-07-18 13:43
(Received via mailing list)
SASADA Koichi <ko1@atdot.net> wrote:
> Hi,
>
> I introduced new API rb_thread_call_without_gvl2() with some documents.
>  Could you review it?
>
> # Of course, the name foo2() is not good.
> # But I can't make good name for it.
> # Good name is welcome.

I agree foo2 is not good.  Naming things is hard and I don't have a
suitable name.

> + *     read_func(void *data, int *skip_check_flag) {
> + *                     // (a) before read
> + *       read(buffer); // (b) reading
> + *                     // (c) after read
> + *       if (read was cpmpleted) {
> + *         *skip_check_flag = 1;
> + *       }
> + *     }

May there be other flags that we may need here in the future?
Perhaps the second argument can be a bitmask to give us more options
in the future:

      read_func(void *data, int *flags) {
        read(buffer);
        if (read was completed) {
          *flags |= RB_NOGVL_SKIP_CHECK;
        }
      }
Posted by SASADA Koichi (Guest)
on 2012-11-16 11:36
(Received via mailing list)
>
Sorry for late response.
I agree with that. I commit your suggestion at r37681.
Posted by SASADA Koichi (Guest)
on 2012-11-28 14:24
(Received via mailing list)
(2012/11/16 19:35), SASADA Koichi wrote:
>>
>
> Sorry for late response.
> I agree with that. I commit your suggestion at r37681.
>

Finally, I decide to change "gvl2" function at r37938.

>   * include/ruby/thread.h (rb_thread_call_without_gvl2): change
>     meaning of function.
>     This function is called with same parameters of
>     `rb_thread_call_without_gvl()'.
>     However, if interrupts are detected, when return immediately.

The trap handler can be invoked *before* gvl function because of
checking interrupt before setting ubf. However, some situation ([Bug
#7134]) this behavior is harmful.

So I decide to make gvl2 as "CHECK_INTS" free version.
Please log in before posting. Registration is free and takes only a minute.
Existing account (Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
No account? Register here.