Forum: Ruby-core Add Queue, SIzedQueue and ConditionVariable implementations in C in addition to ruby ones

C042517d59bed4761cc88681bf71fca8?d=identicon&s=25 Glass_saga (Masaki Matsushita) (Guest)
on 2013-09-05 13:52
(Received via mailing list)
Issue #3620 has been updated by Glass_saga (Masaki Matsushita).

File patch3.diff added

Sorry for my late response.
I fixed a bug in ext/thread.c ([ruby-core:56861]).
It was not compatible with Objects extended by Mutex_m and
test/test_mutex_m.rb failed.
Moreover, I use rb_thread_sleep_deadly() to make it get along with
deadlock detection.

Attached patch includes:
* updated ext/thread.c
* added test from [ruby-core:45950] to test/thread/test_queue.rb
* common.mk rewrited by Nakada-san
----------------------------------------
Feature #3620: Add Queue, SIzedQueue and ConditionVariable
implementations in C in addition to ruby ones
https://bugs.ruby-lang.org/issues/3620#change-41638

Author: panaggio (Ricardo Panaggio)
Status: Assigned
Priority: Normal
Assignee: ko1 (Koichi Sasada)
Category: ext
Target version: next minor


=begin
 Queue, SizedQueue and ConditionVariable are important synchronization
primitives and are nowadays implemented in Ruby.

 Attached patch (initiated by myself and heavily enriched by Nobu)
contains these sync primitives implemented in C, which makes them faster
(see [1] for the benchmark's code):

 Rehearsal -------------------------------------------------
 Q#push          1.590000   0.010000   1.600000 (  1.605502)
 T#push          0.600000   0.010000   0.610000 (  0.630444)
 Q#pop           4.390000   0.000000   4.390000 (  4.389781)
 T#pop           0.580000   0.000000   0.580000 (  0.578918)
 Q#empty?        0.480000   0.000000   0.480000 (  0.484305)
 T#empty?        0.360000   0.000000   0.360000 (  0.358559)
 Q#clear         1.210000   0.000000   1.210000 (  1.214494)
 T#clear         0.600000   0.000000   0.600000 (  0.588611)
 Q#size          0.370000   0.000000   0.370000 (  0.365587)
 T#size          0.350000   0.000000   0.350000 (  0.356985)
 Q#num_waiting   0.380000   0.000000   0.380000 (  0.379199)
 T#num_waiting   0.370000   0.000000   0.370000 (  0.368075)
 --------------------------------------- total: 11.300000sec

 It has already been discussed on ruby-core (see ruby-core:31100).

 This patch is one of the deliverables of my RubySoC project (slot #17):
"Improving Ruby's Synchronization Primitives and Core Libraries" [2,3]

 [1]
http://github.com/panaggio/rubysoc-2010/blob/maste...
 [2] http://pastebin.com/viSnfqe6
 [3] http://rubysoc.org/projects
=end
308cbef6e86dfc49cce3b2d4cf42aedc?d=identicon&s=25 SASADA Koichi (Guest)
on 2013-09-05 14:56
(Received via mailing list)
(2013/09/05 20:52), Glass_saga (Masaki Matsushita) wrote:
> I fixed a bug in ext/thread.c ([ruby-core:56861]).
> It was not compatible with Objects extended by Mutex_m and test/test_mutex_m.rb
failed.
> Moreover, I use rb_thread_sleep_deadly() to make it get along with deadlock
detection.
>
> Attached patch includes:
> * updated ext/thread.c
> * added test from [ruby-core:45950] to test/thread/test_queue.rb
> * common.mk rewrited by Nakada-san

Go ahead.

I'll make another ticket to embed Queue in srcdir/thread.c.
02da662c083396641da96c1d32fc86ed?d=identicon&s=25 KOSAKI Motohiro (Guest)
on 2013-09-12 20:03
(Received via mailing list)
(9/5/13 8:55 AM), SASADA Koichi wrote:
> Go ahead.
>
> I'll make another ticket to embed Queue in srcdir/thread.c.

We already have.

http://bugs.ruby-lang.org/issues/7923
308cbef6e86dfc49cce3b2d4cf42aedc?d=identicon&s=25 SASADA Koichi (Guest)
on 2013-09-18 10:59
(Received via mailing list)
(2013/09/13 3:03), KOSAKI Motohiro wrote:
> We already have.
>
> http://bugs.ruby-lang.org/issues/7923

I feel "making trap safe Queue (Feature #7923)" and embedding Queue
class is not same.
This topic is locked and can not be replied to.