Thread#wakeup in JRuby 1.3.0


#1

Thread#wakeup does not appear to be working in JRuby 1.3.0

$> cat test.rb
STDOUT.sync = true
Thread.abort_on_exception = true

t = Thread.new {
start = Time.now
loop {
puts ‘sleeping’
sleep 5
puts “wake up {Time.now-start}”
break if Thread.current[:stop]
}
}

sleep 0.3
puts ‘stopping’
t[:stop] = true
t.wakeup.join

$> jruby test.rb
sleeping
stopping
wake up [5.015]

$> ruby test.rb
sleeping
stopping
wake up [0.300945]

$> jruby --version
jruby 1.3.0 (ruby 1.8.6p287) (2009-06-03 5dc2e22) (OpenJDK Client VM
1.6.0_0) [i386-java]

$> java -version
java version “1.6.0_0”
OpenJDK Runtime Environment (IcedTea6 1.5) (fedora-18.b16.fc10-i386)
OpenJDK Client VM (build 14.0-b15, mixed mode)

The output from the second run is what I would expect JRuby to produce
as well. The wakeup call to the other thread is not causing it to
break out of the sleep statement. So we just sit there till the full 5
second sleep time has elapsed (instead of waking up immediately and
then breaking out of the loop).

Thanks for JRuby!

Blessings,
TwP


To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email

#2

On Tue, Jun 9, 2009 at 10:32 AM, Tim P.removed_email_address@domain.invalid wrote:

Thread#wakeup does not appear to be working in JRuby 1.3.0

Yep, I saw the bug filed :slight_smile: We’ll have a look at it as soon as we’re
able, and if you can figure anything out you’d obviously help speed
that process along.

  • Charlie

To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email

#3

On Tue, Jun 9, 2009 at 2:20 PM, Charles Oliver
Nutterremoved_email_address@domain.invalid wrote:

known threading issues combined are pretty cumbersome and will
probably affect a lot of people.

I have a trivial local fix for this and I’m writing a test for it. I
think someone needs to do a pass over various thread wakeup scenarios
and write tests/specs for it. This is the second case of an obvious
breakage that was not caught by either tests or specs. I’m going to
get a test in for this and then try to write up some tests for a few
other cases.

  • Charlie

To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email

#4

On Tue, Jun 9, 2009 at 12:53 PM, Tim P.removed_email_address@domain.invalid wrote:

Just wondering if it only occurs on my machine or if it is systemic
with JRuby 1.3.0 on any platform. Anyone else out there want to
confirm?

I’ll look into it as best I can – my Java-fu has many years of dust
upon it. All these @ symbols in the Java code, though, remind me of
Ruby; so that makes me happy :wink:

I’m pretty sure it’s systemic…the logic for making sure sleeps
continue to week when “spurious” woken was still in place although
other parts of the logic that would indicate a normal wakeup were
removed.

I’m currently looking at doing sleeps the way MRI does, by doing a
select on nothing. It should be possible to have the same semantics
without the grossitude of the other version.

I think we’re going to need a 0.0.1 release for this, since the two
known threading issues combined are pretty cumbersome and will
probably affect a lot of people.

  • Charlie

To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email

#5

On Tue, Jun 9, 2009 at 3:23 PM, Charles Oliver
Nutterremoved_email_address@domain.invalid wrote:

I have a trivial local fix for this and I’m writing a test for it. I
think someone needs to do a pass over various thread wakeup scenarios
and write tests/specs for it. This is the second case of an obvious
breakage that was not caught by either tests or specs. I’m going to
get a test in for this and then try to write up some tests for a few
other cases.

I have committed a fix and test for this case in 0fe97c2. I’m going to
look at building out a few more cases with selects and so on to try to
add where we don’t have good testing. Frustrating thing.

I think we’ve decided we’ll either have a 1.3.1 or a really fast 1.4
to get this out the door quickly. I just want to make sure it’s done
right.

  • Charlie

To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email

#6

On Tue, Jun 9, 2009 at 5:59 PM, Charles Oliver
Nutterremoved_email_address@domain.invalid wrote:

look at building out a few more cases with selects and so on to try to
add where we don’t have good testing. Frustrating thing.

I think we’ve decided we’ll either have a 1.3.1 or a really fast 1.4
to get this out the door quickly. I just want to make sure it’s done
right.

Great job!

I vote for a point build. 'Tis a bug fix.

Blessings,
TwP


To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email

#7

On Tue, Jun 9, 2009 at 9:53 AM, Charles Oliver
Nutterremoved_email_address@domain.invalid wrote:

On Tue, Jun 9, 2009 at 10:32 AM, Tim P.removed_email_address@domain.invalid wrote:

Thread#wakeup does not appear to be working in JRuby 1.3.0

Yep, I saw the bug filed :slight_smile: We’ll have a look at it as soon as we’re
able, and if you can figure anything out you’d obviously help speed
that process along.

Thanks, Charlie!

Just wondering if it only occurs on my machine or if it is systemic
with JRuby 1.3.0 on any platform. Anyone else out there want to
confirm?

I’ll look into it as best I can – my Java-fu has many years of dust
upon it. All these @ symbols in the Java code, though, remind me of
Ruby; so that makes me happy :wink:

Blessings,
TwP


To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email