native threads in ruby

R

Rick Penn

Is there anyway possible, one can make use of native threads in Ruby?
Maybe by interfacing with C or Java?
 
C

Charles Oliver Nutter

Rick said:
Is there anyway possible, one can make use of native threads in Ruby?
Maybe by interfacing with C or Java?

JRuby supports native threads today, where each Ruby thread maps to one
native thread. There's also a second option, native thread pooling,
where the number of native threads used is only ever as high as the
number of threads running concurrently.

Normal native thread support is the default. Pooling can be enabled with
a command-line option:

-J-Djruby.thread.pooling=true

- Charlie
 
J

Jason Roelofs

[Note: parts of this message were removed to make it a legal post.]

JRuby supports native threads today, where each Ruby thread maps to one
native thread. There's also a second option, native thread pooling,
where the number of native threads used is only ever as high as the
number of threads running concurrently.

Normal native thread support is the default. Pooling can be enabled with
a command-line option:

-J-Djruby.thread.pooling=true

- Charlie
--enable-threading will put 1.8.6 in native thread mode, but it is unadvised
to do so. Ruby 1.9 does uses native threads as well as a construct called
Fibers, which I think are a better implementation of 1.8.6's green threads.

Jason
 
T

Tom M

[Note: parts of this message were removed to make it a legal post.]

JRuby supports native threads today, where each Ruby thread maps to one
native thread. There's also a second option, native thread pooling,
where the number of native threads used is only ever as high as the
number of threads running concurrently.
Normal native thread support is the default. Pooling can be enabled with
a command-line option:

- Charlie

--enable-threading will put 1.8.6 in native thread mode, but it is unadvised
to do so. Ruby 1.9 does uses native threads as well as a construct called
Fibers, which I think are a better implementation of 1.8.6's green threads.

Jason

I believe that while 1.9 does support native threads, their benefit is
minimal as there is a global interpreter lock most of the time. Is
that correct?
 
C

Charles Oliver Nutter

Tom said:
I believe that while 1.9 does support native threads, their benefit is
minimal as there is a global interpreter lock most of the time. Is
that correct?

That is correct. Ruby 1.9 runs with native threads, but they don't run
concurrently.

- Charlie
 
R

Rick Penn

It looks like I'll be using JRuby. Does JRuby have all the features that
Ruby 1.8.6 has? Are there any plans to incorporate the features in 1.9
to JRuby?

Thanks,
Ryan
 
C

Charles Oliver Nutter

We've done the best job we can making JRuby compatible with Ruby
1.8.6, and hopefully others can attest to that. The only major feature
missing is Continuations, which are a little sketchy with native
threads anyway.

As for 1.9 features, we already have some. For example, we have a port
of the regexp engine 1.9 uses, and a native-thread-backed
implementation of Fibers. We probably won't include more before the
JRuby 1.1 release later this month, but we'll add as many as possible
after that, including all of 1.9's specific optimizations and support
for abitrarily-encoded strings.

- Charlie
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,045
Latest member
DRCM

Latest Threads

Top